我现在遇到这个错误,需要做
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>
我已经尝试了所有方法来修复它,但错误仍然出现。
我的密钥.属性:
storePassword=ul109000
keyPassword=ul109000
keyAlias=sd
storeFile=C:/flutter_project/cursin2/cursin-main/android/app/upload-keystore.jks
在安卓中
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']
}
}
storeFile 路径将为
./upload-keystore.jks
和
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.release
}
}
在我的例子中,key.properties 文件丢失了(你可以在 android/build.gradle 中找到它)。如果您从 github 克隆了存储库,然后尝试创建 appbundle,则可能会出现此问题。
生成新的 key.properties 或使用以前的 key.properties 文件来创建 appbundle。
唯一对我有用的方法是:
flutter clean
例如:
"./upload-keystore.jks"
到
"C:/key/myapp/upload-keystore.jks"
flutter build appbundle
删除此:
debug {
storeFile file(storeFile_)
storePassword storePassword_
keyAlias keyAlias_
keyPassword keyPassword_
}
第一
在
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