android 密钥库密码不正确

xqk2d5yq  于 2023-05-05  发布在  Android
关注(0)|答案(2)|浏览(356)

当我尝试为我的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"
}

这里是我的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

我试过:

  • 清理和重建项目
  • 默认密码(“changeit”,“android”,“password”,“”)
  • 正在删除生成文件夹
  • 重新安装Flutter、Dart和Android Studio
jvidinwx

jvidinwx1#

你把gradle指向key.properties
def keystorePropertiesFile = rootProject.file('key.properties')
密钥库密码不正确
从这看来你的密码是错误的。
如果key.properties文件丢失,它将抛出错误。
在与www.example.com相同的文件夹中local.properties,创建一个key.properties并输入值。
例如

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

ryevplcw2#

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

相关问题