Flutter 无法从存储“key.jks”读取密钥上传。密钥库格式无效

Aay*_*rai 1 java android gradle dart flutter

我正在尝试appbundle使用生成flutter build appbundle --release,当我运行命令时它会抛出以下错误。


FAILURE: Build failed with an exception.

* 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 upload from store "/android/app/key.jks": Invalid keystore format
Run Code Online (Sandbox Code Playgroud)

为了签署应用程序,我遵循了Flutter Android 官方文档

我的app/build.gradle

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

android {
    compileSdkVersion flutter.compileSdkVersion

    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.batuwacab"
        minSdkVersion 20
        targetSdkVersion flutter.targetSdkVersion
        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
       }
   }
}
...
Run Code Online (Sandbox Code Playgroud)

颤振医生

我已存储key.jksandroid/app使用此命令来生成key.jks keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

提前致谢。

Ran*_*lfo 5

我认为您的问题可能是 -storetype 选项,它在您的 keytool 命令行中丢失。这是我的正在工作的。

keytool -genkey -v -keystore upload-keystore.jks -商店类型JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload

我认为在同一点上这条线发生了变化,而您正在使用旧的线。