Flutter release build cannot open the keystore: HmacPBESHA256 not available
Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not availableShort answer
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands. Find which JDK your build really uses and make it the one that made the keystore, or a newer one. If a tool you cannot upgrade must read the file, make a legacy-format copy with keytool.
Fix it fast
1Find out which cause you have
Ask Flutter which Java it uses, then open the keystore with the keytool that belongs to that same JDK. If keytool prints the same error, that Java is older than the one that created the file.
flutter doctor -v /path/to/that/jdk/bin/keytool -list -keystore android/app/upload-keystore.jks2Match what you see, then jump to its fix
- 1
The error appears in flutter build appbundle or apk, while keytool from the JDK you used to create the file opens it without complaintThe JDK running the build is older than the JDK that made the keystoreFix - 2
flutter build works but Gradle started another way fails (./gradlew run by hand, or the IDE's Gradle buttons), or the other way roundFlutter, the terminal and Android Studio each use a different JDKFix - 3
The keystore opens with a current JDK, but an older JDK on a CI image or in another tool fails on the same fileA tool you cannot upgrade has to read the keystoreFix
- 1
What does the error look like?
Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not availableAlgorithm HmacPBESHA256 not available
Cause 1 of 3
The JDK running the build is older than the JDK that made the keystore
1Check
The flutter doctor -v output reports which Java Flutter uses. Flutter takes the one bundled with Android Studio by default, then JAVA_HOME, then any java on the PATH. Compare it with the JDK you ran keytool from when you made the keystore.
flutter doctor -v
echo "$JAVA_HOME"2Fix
Point Flutter at the JDK that created the keystore, or a newer one. The Android Gradle plugin 8.x needs JDK 17 anyway, so a JDK older than that is a problem for the build in any case.
flutter config --jdk-dir=/path/to/jdk-17-or-newer3Verify
Build the release bundle again.
flutter build appbundleConfirmed by docs.flutter.dev
Cause 2 of 3
Flutter, the terminal and Android Studio each use a different JDK
1Check
Flutter picks its own JDK, as above. Gradle started from the buttons in Android Studio uses the JDK chosen in the IDE's Gradle settings. Gradle started by hand in a terminal uses JAVA_HOME if it is set, and otherwise the java on the PATH.
flutter doctor -v
echo "$JAVA_HOME"
java -version2Fix
Make all three use the same JDK: set JAVA_HOME to it, tell Flutter with flutter config, and choose it as the Gradle JDK in Android Studio under Settings, Build, Execution, Deployment, Build Tools, Gradle.
export JAVA_HOME=/path/to/jdk-17-or-newer
flutter config --jdk-dir=/path/to/jdk-17-or-newer3Verify
Open a new terminal, run the release build there, then run it again from the IDE.
flutter build appbundleConfirmed by developer.android.com
Cause 3 of 3
A tool you cannot upgrade has to read the keystore
1Check
The JDK security settings note that some PKCS12 tools and libraries do not support the newer algorithms. Run the same keytool command with the older JDK and the newer one and compare.
keytool -list -keystore android/app/upload-keystore.jks2Fix
With the newer JDK, write a copy that uses the legacy PKCS12 algorithms and point the older tool at the copy. Keep the original file, because the original is your signing key. The JDK documentation says to use this setting at your own risk.
keytool -J-Dkeystore.pkcs12.legacy -importkeystore \
-srckeystore android/app/upload-keystore.jks \
-destkeystore android/app/upload-keystore-legacy.jks \
-srcstoretype pkcs12 -deststoretype pkcs123Verify
List the copy with the older JDK's keytool, then update storeFile in android/key.properties and build again.
keytool -list -keystore android/app/upload-keystore-legacy.jks
flutter build appbundleConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Keep one JDK for Android builds and set it with flutter config --jdk-dir, so every machine builds with the same Java.
- Create a new upload keystore with the keytool command from Flutter's Android release guide, which names the store type explicitly.
- Back up the keystore and its passwords in a password manager before you change anything about it.
- Pin the same JDK in CI as on your own machine.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Signing a release build stops with Failed to read key from keystore
Failed to read key from keystore
Gradle opened the signing config but could not get the key out of the keystore.
3 causes, each with a fixMobile apps
Flutter Android build fails: Java is too new for this Gradle version
Unsupported class file major version 61
Gradle only runs on Java versions it knows.
3 causes, each with a fixMobile apps
Flutter Android: Failed to load FirebaseOptions from resource
Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.
On Android, Firebase reads its settings from a values.xml file that the Google services Gradle plugin builds from google-services.json.
4 causes, each with a fixMobile apps
Flutter Android build stops with Execution failed for task ':app:…'
Execution failed for task ':app:compileFlutterBuildRelease'.
The line only tells you which Gradle step broke; the task name in the quotes tells you why.
5 causes, each with a fixMobile apps
Flutter's Android build stops: JAVA_HOME is not set
ERROR: JAVA_HOME is set to an invalid directory
The Gradle wrapper script needs a Java runtime and looks in two places: the JAVA_HOME variable, then a java command on PATH.
3 causes, each with a fixMobile apps
flutter_local_notifications crashes on Android with Integer.intValue() on a null object reference
NullPointerException in setSmallIcon
The crash comes from the small icon.
2 causes, each with a fix