Flutter:任务“:app:validateSigningRelease”执行失败。 > 密钥库文件未设置用于签署配置版本

Posted

技术标签:

【中文标题】Flutter:任务“:app:validateSigningRelease”执行失败。 > 密钥库文件未设置用于签署配置版本【英文标题】:Flutter: Execution failed for task ':app:validateSigningRelease'. > Keystore file not set for signing config release 【发布时间】:2021-12-21 14:56:23 【问题描述】:

在开发 Flutter 应用程序时,我已经尝试了之前列出的所有修复,但没有任何效果。我相信一切都已正确配置且位于正确的位置,因此我需要帮助找出签名配置仍然引发此错误的原因。我已经尝试了几个小时来寻找另一个没有运气的解决方案。一切都拼写正确。错误如下。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release

key.properties 文件夹在 android 主文件夹中,upload-keystore.jks 文件在 android/app 中。

key.properties 是

storePassword=xxxx
keyPassword=xxxx
keyAlias=upload
storeFile=/Users/..../android/app/upload-keystore.jks

完整的build.gadle

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"
apply plugin: 'com.google.gms.google-services'  // Google Services plugin

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


android 
    compileSdkVersion 30

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

    lintOptions 
        disable 'InvalidPackage'
    

    defaultConfig 
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.fytfeed.fytfeed"
        minSdkVersion 23
        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"

【问题讨论】:

【参考方案1】:

好吧,在我用头撞墙一天之后,我想出了这个问题。我的key.properties 文件夹中有一个未知空间,位于引发错误的文件名的开头。因此,如果一切正常,请注意随机空间!

【讨论】:

【参考方案2】: 重新生成密钥

在 Android Studio 中打开项目“/android”

构建 -> 生成签名包/APK ..

完成步骤...

【讨论】:

【参考方案3】:

只需在 key.properties 中选择 JKS 文件的正确路径并重新运行

【讨论】:

以上是关于Flutter:任务“:app:validateSigningRelease”执行失败。 > 密钥库文件未设置用于签署配置版本的主要内容,如果未能解决你的问题,请参考以下文章

任务':app:compressDebugAssets'的Flutter执行失败

Flutter - 任务':connectivity:compileDebugJavaWithJavac'的执行失败

任务':app:mergeDebugResources'的Flutter构建失败

任务':app:processDebugManifest'的Flutter执行失败

如何在 Flutter 创建一个后台任务

Flutter:FAILURE:构建失败,出现异常无法创建任务':app:compileFlutterBuildDebug'。必须提供 Flutter 源码目录