[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain incompatibility between Java versions #5871

Closed
rongpenl opened this issue May 28, 2021 · 29 comments
Closed

Explain incompatibility between Java versions #5871

rongpenl opened this issue May 28, 2021 · 29 comments
Labels
a.rn.breaking-changes Relates to breaking changes on a Flutter release cl.fixed Issue is closed as fixed d.enhancement Improves docs with specific ask e2-days Effort: < 5 days p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged target.Android Target apps on the Android Platform

Comments

@rongpenl
Copy link

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

@rongpenl
Copy link
Author

It looks like changing genkey to genkeypair works.

@Alhaadi-IDB
Copy link

i still facing this issue, genkeypair not working for me. Show same error.. please help..

@Shyam-Sundar-Bharathi
Copy link

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.

@Alhaadi-IDB
Copy link

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.

@rongpenl
Copy link
Author
rongpenl commented Jun 7, 2021

@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

@Shyam-Sundar-Bharathi
Copy link

@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.

@Shyam-Sundar-Bharathi
Copy link

@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.

@Akkamar
Copy link
Akkamar commented Jun 16, 2021

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.

@moatazfouad
Copy link

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

@darshankawar darshankawar added the st.triage.triage-team Triage team reviewing and categorizing the issue label Jul 29, 2021
@darshankawar
Copy link
Member

@rongpenl
Is this still a valid issue or does #5871 (comment) or above solutions helps to resolve this ?

@rongpenl
Copy link
Author

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.

@darshankawar
Copy link
Member

An update or "warning" on the official site is probably helpful.

Labeling per above comment.

@darshankawar darshankawar added p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. e2-days Effort: < 5 days d.enhancement Improves docs with specific ask and removed waitingForCustomerResponse st.triage.triage-team Triage team reviewing and categorizing the issue labels Aug 11, 2021
@KhalidWar
Copy link

@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.

@chris-otani
Copy link
chris-otani commented Sep 22, 2021

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?

@shirishkoirala
Copy link

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.

@BarNce
Copy link
BarNce commented Oct 25, 2021

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.

@chris-otani
Copy link

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.

@gracecarrillo
Copy link
gracecarrillo commented Nov 6, 2021

@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.

@BarNce
Copy link
BarNce commented Nov 8, 2021

@gracecarrillo It turned out to be impossible to contact google support. Your answer completely solved my problem. Thanks!

@Childe-Tartaglia
Copy link

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.
image

@alymbouras
Copy link

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

@arvi
Copy link
arvi commented Feb 22, 2022

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).

@sohaibqureshi234
Copy link

facing same issue

@sohaibqureshi234
Copy link
  • 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

@MohammedFouadx
Copy link

Akkama

Hi, I am so thankful. I have tried many things before but it did not work.
You saved my life ❤

@denysvitali
Copy link

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

@AliJ91
Copy link
AliJ91 commented May 31, 2022

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

@Alhaadi-IDB
Copy link

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.

@atsansone
Copy link
Contributor

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 #8501. Closing this issue.

@atsansone atsansone added st.triage.ltw Indicates Lead Tech Writer has triaged target.Android Target apps on the Android Platform a.rn.breaking-changes Relates to breaking changes on a Flutter release cl.fixed Issue is closed as fixed labels Jun 2, 2023
@atsansone atsansone changed the title HmacPBESHA256 not available. Explain incompatibility between Java versions Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.rn.breaking-changes Relates to breaking changes on a Flutter release cl.fixed Issue is closed as fixed d.enhancement Improves docs with specific ask e2-days Effort: < 5 days p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged target.Android Target apps on the Android Platform
Projects
None yet
Development

No branches or pull requests