“:app:signReleaseBundle” 任务执行失败。

10
我目前在执行 flutter build appbundle 命令时遇到了以下错误:

错误信息如下:

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 sd from store "C:\flutter_project\cursin2\cursin-main\android\app\upload-keystore.jks": Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Running Gradle task 'bundleRelease'...                              9,1s
Gradle task bundleRelease failed with exit code 1
PS C:\flutter_project\cursin2\cursin-main> 

这里输入图片描述

我已经尝试了所有方法来修复它,但错误仍然出现。

我的key.properties:

storePassword=ul109000
keyPassword=ul109000
keyAlias=sd
storeFile=C:/flutter_project/cursin2/cursin-main/android/app/upload-keystore.jks

我已经尝试过:flutter clean,删除密钥库,重试生成密钥... - Carlos Peñaranda
5个回答

5

在安卓中的app/build.gradle文件中

android标签内部

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

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

存储文件路径将为 ./upload-keystore.jks

还有:

 buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.release
        }
    }

谢谢,我已经实现了。但是出现了这个错误:52: 当前作用域已经包含了一个名为keystoreProperties的变量 @第52行,第9列。 def keystoreProperties = new Properties() ^ - Carlos Peñaranda
我已经更改了那些名称,但现在出现了这个错误:“在执行com.android.build.gradle.internal.tasks.Workers $ ActionFacade时发生故障>无法从存储库“C:\ flutter_project \ cursin2 \ cursin-main \ android \ app \ upload-keystore.jks”中读取键sd:完整性检查失败:java.security.NoSuchAlgorithmException:算法HmacPBESHA256不可用”。 - Carlos Peñaranda
你可以检查一下最后一个错误。看起来是密钥库文件的问题: https://dev59.com/rFEG5IYBdhLWcg3wVqz9 - Hardik Mehta
Flutter文档表示将该代码放置在android块之前。https://docs.flutter.dev/deployment/android - alfietap

3

我遇到这个问题,唯一有效的解决方法是:

  1. 运行flutter clean
  2. 编辑我在密钥属性中使用的路径。

例如:将"./upload-keystore.jks"修改为"C:/key/myapp/upload-keystore.jks"

3. 运行flutter build appbundle


3
在我的情况下,key.properties 文件丢失了(你可以在 android/build.gradle 中找到它)。如果你是从 Github 克隆了你的 repo,然后尝试创建 appbundle,那么可能会出现这个问题。
生成新的 key.properties 或者使用之前的 key.properties 文件来创建 appbundle。

0

删除这个:

debug {
    storeFile file(storeFile_)
    storePassword storePassword_
    keyAlias keyAlias_
    keyPassword keyPassword_
}

0

首先

android app/build.gradle 文件中

将以下内容替换为

   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }

使用这个

   buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.release
        }
   }

第二步

在您的生成路径中删除upload-keystore.jks,在我的情况下(Ubuntu操作系统)路径为/home/user/upload-keystore.jks

第三步

生成一个带有额外属性的新密钥

-storetype JKS

适用于Linux

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storetype JKS

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接