DEV Community

Curtly Critchlow
Curtly Critchlow

Posted on

How to fix java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available when building app bundle

Indroduction

In this article I'll share with you how I fixed a failed flutter build app bundle command.

When I ran flutter build app bundle in my terminal I got the below error.

Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > Failed to read key upload from store "/Users/<your folder name>/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 8s
Enter fullscreen mode Exit fullscreen mode

Solution

The likely cause of this error is because the java version the app is built with is different for the java version being used to generate the signing key.

To fix run

Run flutter doctor -v
Enter fullscreen mode Exit fullscreen mode
...
[✓] Android toolchain - develop for Android devices (Android SDK version
    34.0.0-rc2)
    • Android SDK at /Users/<your folder path>/Library/Android/sdk
    • Platform android-33, build-tools 34.0.0-rc2
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

...
Enter fullscreen mode Exit fullscreen mode

Prefix the keygen command to point to the java version used to build your app and run you keygen command as shown below.

/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home/bin/keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Enter fullscreen mode Exit fullscreen mode

Run flutter build appbundle and your build will be successful

Connect with me

Thank you for reading my post. Feel free to like, comment, subscribe or connect with me on LinkedIn and Twitter. You can also buy me a book to show your support.

Top comments (1)

Collapse
 
yosefschwartz profile image
Yosef Schwartz

i got zsh: no such file or directory: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool