Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter release build cannot open the keystore: HmacPBESHA256 not available

ErrorIntegrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available

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

  • Applies to Flutter 3.3x, JDK 17 or newer, Gradle 8 or 9, Android Gradle plugin 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.jks
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2flutter 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. 3The 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

What does the error look like?

  • Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available
  • Algorithm 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-newer

3Verify

Build the release bundle again.

flutter build appbundle

Confirmed by docs.flutter.dev

Did this fix it?

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 -version

2Fix

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-newer

3Verify

Open a new terminal, run the release build there, then run it again from the IDE.

flutter build appbundle

Confirmed by developer.android.com

Did this fix it?

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

2Fix

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 pkcs12

3Verify

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 appbundle

Confirmed by raw.githubusercontent.com

Did this fix it?

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:

Related fixes

Mobile 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 fix

Mobile 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.