android - 构建 Flutter 应用的 RELEASE 版本会返回此错误
问题描述
我正在准备在 Playstore 中发布我的颤振应用程序,它给了我这个错误:
错误:
* Where:
Build file 'C:\Users\svesp\Desktop\Vlad Esplana\syncshop_webview\android\app\build.gradle' line: 60
* What went wrong:
A problem occurred evaluating project ':app'.
> path may not be null or empty string. path='null'
我的key.properties
:
storePassword=hidden
keyPassword=hidden
keyAlias=random
storeFile=C:/Users/svesp/key.jks
我的应用级别build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.hivemanila.syncshop_webview"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['hidden']
keyPassword keystoreProperties['hidden']
storeFile file(keystoreProperties['C:/Users/svesp/key.jks'])
storePassword keystoreProperties['hidden']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
解决方案
只需将您的签名配置更改为以下,
signingConfigs {
release {
keyAlias keystoreProperies["keyAlias"]
keyPassword keystoreProperies["keyPassword"]
storeFile file(keystoreProperies["storeFile"])
storePassword keystoreProperies["storePassword"]
}
}
只需替换您的代码
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
至
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperiesFile = rootProject.file("key.properties")
def keystoreProperies = new Properties()
keystoreProperies.load(new FileInputStream(keystoreProperiesFile))
推荐阅读
- php - 我在 wordpress 中开发了一个自定义主题,但 css 文件无法通过 function.php 发出声音
- python - Django 处理多个模型的外键
- html - 如何使用内联 CSS 更改表格字体/内容的颜色
- node.js - 带有嵌套数组的 React-Table,无法访问嵌套内容
- ios - 在 UICollectionView 中加载图像时,SDWebImage 5.0 崩溃
- c - 为什么在 realloc 不能使用 MVC++ 之后为指针赋值
- javascript - 如何使用 jsPDF 和 html2Canvas 计算转换为图像以适合 PDF 的 div 高度?
- mysql - 使用node.js将数据插入mysql时如何解决错误
- c - C: 我有一个简单的快餐交易程序,如何自动打印订购食物的收据?
- c# - 如何获取属于本地系统组的域用户 SID