website
website copied to clipboard
HmacPBESHA256 not available.
Page URL: https://flutter.dev/docs/deployment/android.html Page source: https://github.com/flutter/website/tree/master/src/docs/deployment/android.md
Found a typo? You can fix it yourself by going to the page source and clicking the pencil icon. Or finish creating this issue.
Description of issue:
It looks like the latest Android Studio has builtin java 11. And HmacPBESHA256 is only supported starting with java 12. See this stackoverflow question.
Therefore the following error happens when running 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 upload from store "/Users/ronli/upload-keystore.jks": Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available
It looks like changing genkey
to genkeypair
works.
i still facing this issue, genkeypair not working for me. Show same error.. please help..
I'm having the same issue. I tried just about everything to resolve it for the past 5 hours. But it simply persists. I read that the Java version shipped with Android Studio doesn't have the SHA-256 algorithm. Help would be much appreciated.
I Solved my problem after about 2 weeks facing this issue, turn out my MAC java is java 18 and android studio default run java 11, so i change my MAC java Home path to run java 11, then run flutter clean create the file keystroke again, then all good now.
@Alhaadi-IDB Interesting because java 11 didn't have that algorithm. Can you provide more details? What's the output of this command on your machine?
/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/java --version
FYI for whoever reads the issue, this is the StackOverflow question: https://stackoverflow.com/questions/67631927/error-building-aab-flutter-android-integrity-check-failed-java-security-n/67632064?noredirect=1#comment119760622_67632064
@Alhaadi-IDB Interesting because java 11 didn't have that algorithm. Can you provide more details? What's the output of this command on your machine?
/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/java --version
FYI for whoever reads the issue, this is the StackOverflow question: https://stackoverflow.com/questions/67631927/error-building-aab-flutter-android-integrity-check-failed-java-security-n/67632064?noredirect=1#comment119760622_67632064
Yes. This works. That's the first thing I saw, however, for some reason, I decided to try everything in the world for 1 entire night before finally trying that and it works like a charm.
@Alhaadi-IDB That's one way to do it but in my opinion, I'm not sure if it's the best way. So basically by switching to Java 11, you're using a less secure version of SHA which may be a security threat. SHA256withRSA is advisable, but only available from after Java 12. I don't know if the Stack Overflow solution uses SHA256 either, but the terminal warns when we use lesser encryption and that didn't happen. So I'm assuming that's the best option.
Hi all,
as I think I had the same issue. I now tried the command keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storetype JKS
with the addtional -storetype JKS
and it worked. In the docs, there is only the version without this parameter for Mac/Linux specified. Omitting this option leads to the same error (https://github.com/flutter/website/issues/5871#issue-906178960) above.
If you are still facing this issue, Update Android Studio IDE to the latest version 4.2
and regenerate the jks file again then build your apk
or appbundle
.
and the issue will not appear again.
Steps to update Android Studio
In the main page of Android Studio go to this path
Configure/Preferences/Appearance & Behavior/System Settings/Updates
and press Check Now for checking any updates
@rongpenl Is this still a valid issue or does https://github.com/flutter/website/issues/5871#issuecomment-855597669 or above solutions helps to resolve this ?
Hi @darshankawar,
I am not actively monitoring this issue. Sorry for the late reply. I solved the issue on my side with a different way ( as I replied earlier). I guess there are many ways to solve this issue. An update or "warning" on the official site is probably helpful.
An update or "warning" on the official site is probably helpful.
Labeling per above comment.
@Alhaadi-IDB Interesting because java 11 didn't have that algorithm. Can you provide more details? What's the output of this command on your machine?
/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/java --version
FYI for whoever reads the issue, this is the StackOverflow question: https://stackoverflow.com/questions/67631927/error-building-aab-flutter-android-integrity-check-failed-java-security-n/67632064?noredirect=1#comment119760622_67632064
This worked for me after struggling for hours.
I generated keys at the start of the project and they worked fine until recently I got this error.
I was able to generate a new key successfully to sign my app bundle. The problem is now when I upload it to the Android play console I get "Your Android App Bundle is signed with the wrong key...."
So generating new keys is not a valid solution for me since my app is already in production.
Is there a way to add HmacPBESHA256 to an already existing key?
Hi everyone, I got the same issue yesterday. I deleted my old debug key, which is located at /Users/<username>/.android/debug.keystore
. Hope this helps. Thanks.
I generated keys at the start of the project and they worked fine until recently I got this error.
I was able to generate a new key successfully to sign my app bundle. The problem is now when I upload it to the Android play console I get "Your Android App Bundle is signed with the wrong key...."
So generating new keys is not a valid solution for me since my app is already in production.
Is there a way to add HmacPBESHA256 to an already existing key?
I faced the same problem. I tried all the suggested methods, nothing helps. I just can't release an update to the application.
I generated keys at the start of the project and they worked fine until recently I got this error. I was able to generate a new key successfully to sign my app bundle. The problem is now when I upload it to the Android play console I get "Your Android App Bundle is signed with the wrong key...." So generating new keys is not a valid solution for me since my app is already in production. Is there a way to add HmacPBESHA256 to an already existing key?
I faced the same problem. I tried all the suggested methods, nothing helps. I just can't release an update to the application.
I gave up and finally had to email google my new keys and have them update them.
@chris-otani Like you, generating new keys was not an option because our app is already in production and contacting google was such a hassle. As others have pointed out, the build fails because the app was signed with a java version higher than Java 11. But the HmacPBESHA256 algorithm is not available in java 11 which is shipped with Android Studio.
So the solution was to get Android Studio to build the aab with your local java version, not java 11. To specify the JDK version, in gradle.properties
, I added:
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
<- Substitute with your java home path
After this, I was able to build my aab without any issues with the keys I already had.
@gracecarrillo It turned out to be impossible to contact google support. Your answer completely solved my problem. Thanks!
Just change the settings of Android Studio; change the Gradle JDK to higher version from default java 11.
And then the problem can be solved.
Hi all,
as I think I had the same issue. I now tried the command
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storetype JKS
with the addtional-storetype JKS
and it worked. In the docs, there is only the version without this parameter for Mac/Linux specified. Omitting this option leads to the same error (#5871 (comment)) above.
I have spent quite a lot of time on this. Nothing was working for me. What worked for me was: -deststoretype JKS
instead of: -storetype JKS
I Solved my problem after about 2 weeks facing this issue, turn out my MAC java is java 18 and android studio default run java 11, so i change my MAC java Home path to run java 11, then run flutter clean create the file keystroke again, then all good now.
@Alhaadi-IDB Thank you! This is what worked for me.
I am using zsh and in Mac OS Catalina so I edited .zshrc by adding
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home/"
save it, close existing terminals and open again to check versions if they are the same already
flutter doctor -v
java --version
Then I went to add key in /android/app/ (added in .gitignore)
keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Added key.properties in /android (added in .gitignore):
storePassword=pwhere
keyPassword=pwhere
keyAlias=key
storeFile=key.jks
Then flutter clean
Then flutter build appbundle
With result:
Changing current working directory to: /Users/name/flutterapp
Running "flutter pub get" in flutterapp... 2,102ms
💪 Building with sound null safety 💪
/Users/name/flutterapp/android/key.properties
Removed unused resources: Binary resource data reduced from 556KB to 486KB: Removed 12%
Running Gradle task 'bundleRelease'... 107.9s
✓ Built build/app/outputs/bundle/release/app-release.aab (20.3MB).
facing same issue
- What went wrong: Execution failed for task ':app:packageDebug'.
A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "C:\Users\annonymous.android\debug.keystore": Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available
Akkama
Hi, I am so thankful. I have tried many things before but it did not work. You saved my life ❤
Just change / set the gradle.properties
option org.gradle.java.home
.
If you are using Arch Linux, it's as easy as:
org.gradle.java.home=/usr/lib/jvm/default
I Solved my problem after about 2 weeks facing this issue, turn out my MAC java is java 18 and android studio default run java 11, so i change my MAC java Home path to run java 11, then run flutter clean create the file keystroke again, then all good now.
And how did you do that? I think im facing the same issue
I Solved my problem after about 2 weeks facing this issue, turn out my MAC java is java 18 and android studio default run java 11, so i change my MAC java Home path to run java 11, then run flutter clean create the file keystroke again, then all good now.
And how did you do that? I think im facing the same issue
Make sure ur java HOME version is similar with the java version use in Android Studio. Can google on how to check and set the java version for ur OS and Android studio.
This issue has been documented at https://docs.flutter.dev/release/breaking-changes/android-java-gradle-migration-guide to cover a similar situation. Fixed in https://github.com/flutter/website/pull/8501. Closing this issue.