【发布时间】:2021-04-27 02:29:09
【问题描述】:
嘿,我需要你的帮助。我知道这个错误有很多线程,但我尝试了每一个解决方案,但没有任何效果。
我按照文档中提到的所有方法来获取我的应用程序包,但我总是收到此错误:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release
我像这样制作了key.properties并将其保存在android文件夹中(C:\Users\Martin\Documents\tutorial\android):
storePassword=XXXXXX
keyPassword=XXXXXX
keyAlias=key
storeFile=/Users/Martin/key.jks
我创建了自己的密钥库文件,该文件位于 /Users/Martin/
And finally I changed my build.gradle as mentioned in the documentation.
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'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('app/key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
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.example.myID"
minSdkVersion 16
targetSdkVersion 29
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:26.1.1')
implementation 'com.google.firebase:firebase-auth'
}
我不知道这是否有帮助,但如果我尝试调试模式
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
一切正常,一切正常。
√ Built build\app\outputs\bundle\release\app-release.aab (20.0MB).
什么可能会在发布模式下导致此错误但在调试模式下工作?感谢您的帮助。
【问题讨论】:
-
试试this。您应该更正 Gradle 属性的路径(从
local.properties到app/local.properties)。 -
这会导致以下错误:* 其中:构建文件 'C:\Users\Martin\Documents\tutorial\maulwurf\android\app\build.gradle' 行:11 * 出了什么问题:A评估项目“:app”时出现问题。 > 未找到 Flutter SDK。在 local.properties 文件中使用 flutter.sdk 定义位置。
-
将变量
flutter.sdk添加到具有 Flutter SDK 有效路径的local.properties文件中。 -
我是初学者,你能指导我怎么做吗?
-
只需将
flutter.sdk=path_to_sdk(其中path_to_sdk是您的Flutter SDK 的有效路径(如/Users/user/flutter/bin))添加到local.properties。
标签: android flutter apk android-app-bundle