【问题标题】:failed for task :app:signReleaseBundle'A failure executing com.android.build.gradle.internal.tasks.Workers$ActionFacade, Failed to read key from store任务失败:app:signReleaseBundle'执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 失败,无法从存储中读取密钥
【发布时间】:2021-11-10 19:09:53
【问题描述】:

当我构建一个发布的 .abb Flutter 应用程序时,我遇到了一个问题,我花了 2 周多的时间寻找解决这个问题的方法,但这些解决方案都没有奏效,所以我希望你能帮助我。

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Failed to read key final.jks from store "D:\keys\final.jks": No key with alias 'final.jks' found in keystore D:\keys\final.jks

我尝试过的解决方案:

  1. 我已经确定了密钥库文件目录和密码”的密码。
  2. 再次生成密钥库以确保其密码。
  3. build.gradle 的每次更改后我都跑得干净利落
  4. classpath 'com.android.tools.build:gradle:4.1.0' 更改为classpath 'com.android.tools.build:gradle:3.5.0'
  5. 将密钥库文件路径从 C: 更改为 D:
  6. 将key.properties文件的路径从/android/app更改为/android
  7. 删除了C:驱动中的主.gradle文件并通过Android Studio重新下载
  8. 最后我尝试构建apk,但出现了同样的问题。

这是/android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是/android/app/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'
}


apply plugin: 'com.android.application'
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 30

    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.example.counter"
        minSdkVersion 16
        targetSdkVersion 30
        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"
}

key.properties文件:

storePassword=123456
keyPassword=123456
keyAlias=final.jks
storeFile=D:/keys/final.jks

我的Android studio version is "Arctic Fox 2020.3.1"flutter SDK version is 2.5

这是我的第一个应用程序,希望您能帮助我,谢谢!

【问题讨论】:

  • 您好,请从“storeFile”中删除内容,留空。然后运行“flutter clean && flutter pub get”再运行“flutter build appbundle”
  • 杰西洛佩斯佩雷拉,感谢您的回复,但我仍然收到错误
  • 报错说别名错误,你可以打开android studio里面的android文件夹,在tools中选择generate signed apk。这将消除您自己命名别名的问题,您所要做的就是提供 Keystore 密码,它会自动检测别名并为您签署应用程序。

标签: android flutter android-studio dart gradle


【解决方案1】:

第 1 步

将 final.jks 文件放在 /android/app 文件夹中

第 2 步

key.properties

storePassword=123456
keyPassword=123456
keyAlias=final
storeFile=final.jks

【讨论】:

  • 确保在创建 Keystore 时将别名命名为 final
  • Priyansu Choudhury,感谢您的回复,但不幸的是,我仍然遇到同样的错误,谢谢
猜你喜欢
  • 2021-05-29
  • 1970-01-01
  • 1970-01-01
  • 2022-08-17
  • 2023-04-05
  • 2018-07-19
  • 2017-07-16
  • 2016-09-17
  • 1970-01-01
相关资源
最近更新 更多