密钥店密码不正确

发布于 2025-02-08 10:22:26 字数 3287 浏览 1 评论 0原文

当我尝试为我的Flutter应用程序创建签名捆绑包时,我会得到

Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > Failed to read key key0 from store "/Users/username/keystores": keystore password was incorrect

正确的密码,我知道这是因为我写下来。我的密码只有数字和基本字母。当我运行时,

./gradlew signingReport

当我第一次尝试使用密钥库时,我会

Variant: release
Config: release
Store: /Users/myname/keystores
Alias: key0
Error: Failed to read key key0 from store "/Users/myname/keystores": keystore password was incorrect

发生同样的故障,但随后我能够通过清洁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 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "myApplicationId"
        minSdkVersion 24
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources false
            minifyEnabled false
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

sdk.dir=/Users/myName/Library/Android/sdk
flutter.sdk=/users/myName/developer/flutter
flutter.buildMode=release
flutter.versionName=0.1.5
flutter.versionCode=6

  • 本地
  • 是 工作室

When I try to create signed bundle for my flutter app I get

Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > Failed to read key key0 from store "/Users/username/keystores": keystore password was incorrect

I have the correct password and I know this because I wrote it down. My password has only numbers and basic letters. When I run

./gradlew signingReport

I get

Variant: release
Config: release
Store: /Users/myname/keystores
Alias: key0
Error: Failed to read key key0 from store "/Users/myname/keystores": keystore password was incorrect

This same failure happened when I tried to use the keystore for the first time but then I was able to fix it by cleaning the android project. But now the cleaning does not work anymore.

Here is my 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 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "myApplicationId"
        minSdkVersion 24
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources false
            minifyEnabled false
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

Here is my local.properties

sdk.dir=/Users/myName/Library/Android/sdk
flutter.sdk=/users/myName/developer/flutter
flutter.buildMode=release
flutter.versionName=0.1.5
flutter.versionCode=6

I have tried:

  • Cleaning and rebuilding the project
  • Default passwords ("changeit", "android", "password", "")
  • Removing build folder
  • Reinstalling Flutter, Dart and Android studio

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

还如梦归 2025-02-15 10:22:26

您指向key.properties

def keystorepropertiesfile = rootproject.file('key.properties')

密钥库密码不正确

似乎是错误的,好像您的密码是错误的。

如果缺少key.properties文件,它将丢弃错误。

在与local.properties的同一文件夹中,创建一个key.properties并输入您的值。

例如

storePassword=mysecretpassword
keyPassword=mysecretpassword
keyAlias=mykeyalias (if not sure it might be key0)
storeFile=.pathtokeyfile/key.jks

you point gradle to key.properties

def keystorePropertiesFile = rootProject.file('key.properties')

keystore password was incorrect

From this seems like your password is wrong.

If key.properties file is missing it will throw errors.

In the same folder as local.properties, create a key.properties and enter you values.

eg

storePassword=mysecretpassword
keyPassword=mysecretpassword
keyAlias=mykeyalias (if not sure it might be key0)
storeFile=.pathtokeyfile/key.jks

怕倦 2025-02-15 10:22:26

我遇到了同样的问题,但是我所做的就是转到我的家庭位置文件并删除upload-keystore.jks文件,一切正常

I had the same issue but what I did was to go to my home location file and delete the upload-keystore.jks file and everything worked fine

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文