构建Appbundle(Flutter)时密钥库密码不正确

Her*_*tiz 4 android gradle dart flutter android-app-bundle

所以我目前正在尝试创建一个应用程序包,以便我可以将我的应用程序上传到谷歌游戏商店。不幸的是,我在项目的签名发布部分遇到了问题。以下是来自终端的错误的副本:

FAILURE: Build failed with an exception.                                

* What went wrong:                                                      
Execution failed for task ':app:packageRelease'.                        
> com.android.ide.common.signing.KeytoolException: Failed to read key key from store "/Users/herb/Downloads/morningly/android/app/key.jks": keystore password was incorrect
Run Code Online (Sandbox Code Playgroud)

我对这个错误背后的思考过程是,我设置 key.properties 的方式或 app/build.gradle 中的某些内容存在错误。以下是两个文件:

Key.properties
Run Code Online (Sandbox Code Playgroud)
storePassword=<REDACTED>
keyPassword=<REDACTED>
keyAlias=key
storeFile=key.jks
Run Code Online (Sandbox Code Playgroud)

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'
}

def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }

   apply plugin: 'com.android.application'
   android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.morningly"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
    dependencies {
            implementation 'com.android.support:support-fragment:28.0.0'
            implementation 'android.arch.lifecycle:common-java8:1.1.0'
        }
}

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

Run Code Online (Sandbox Code Playgroud)

我仔细检查了一下,我知道密码是正确的,但如果有任何可以替换的东西,那可能会有所帮助。如果您有任何意见,请告诉我。我非常想尽快上传该应用程序。

Mik*_*fik 10

您的错误密钥库密码不正确

关于不带 <> 的 Key.properties

删除<>

storePassword=password
keyPassword=password
keyAlias=key
storeFile=key.jks
Run Code Online (Sandbox Code Playgroud)

关于应用程序/build.gradle

你错过了很多

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
Run Code Online (Sandbox Code Playgroud)

这是我的文件更改 applicationId

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 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 29

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.your bannel"
        minSdkVersion 18
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

否则

您可以将谷歌连接到休息密钥,并在他们允许后创建新的密钥吗

https://support.google.com/googleplay/android-developer/contact/otherbugs