我正在使用已創建的密鑰庫檔案創建發布版本。將檔案放在 android/app/AlZarooniKS 中。當從 android studio 執行構建 apk 時,它在 assembleRelease 中給出錯誤,但在 assembleDebug 中作業正常。我收到以下例外。
* What went wrong:
Execution failed for task ':app:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> com.android.ide.common.signing.KeytoolException: Failed to read key AlZarooniKS from store "/Users/hammas/Desktop/parking/android/app/AlZarooniKS": Cannot recover key
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Running Gradle task 'assembleRelease'... 16.6s
Gradle task assembleRelease failed with exit code 1
我的 key.properties 檔案
storePassword=xxx
keyPassword=xxx
keyAlias=AlZarooniKS
storeFile=/Users/hammas/Desktop/parking/android/app/AlZarooniKS
這是 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 FileNotFoundException("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'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs = 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.quaidtech.emirates_parking"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion flutter.targetSdkVersion
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"
}
uj5u.com熱心網友回復:
- 確保您使用無效的密鑰名稱和密碼
.jks在您的 key.property 中使用以“”結尾的密鑰路徑- 如果失敗使用新別名創建另一個發布密鑰
uj5u.com熱心網友回復:
在 flutter clean && flutter pub get && flutter run 之后,降級 kotlin 版本和 gradle 插件為我做了這件事
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/534233.html
上一篇:無法在本機反應中構建apk
