Error building AAB - Flutter (Android) - Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available

12,989

Solution 1

I was getting the same error, I try this command

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storetype JKS

with extra attribute

-storetype JKS

it helps me to solve my problem and successfully create bundle.

The -storetype JKS tag is only required for Java 9 or newer. As of the Java 9 release, the keystore type defaults to PKS12.

Solution 2

It turns out i was generating my signing key using a different Java Version than my app was using to build the app. You can check this by running flutter doctor -v and seeing where the Java binary is located, and comparing it to when you run "which java".

The solution is to run your keygen command prefixed with the location of the Java bin found in the flutter doctor output like so:

/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool -genkey -v -keystore ~/pc-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias pckey

Solution 3

Note: The keytool command might not be in your path—it’s part of Java, which is installed as part of Android Studio. For the concrete path, run flutter doctor -v and locate the path printed after ‘Java binary at:’. Then use that fully qualified path replacing java (at the end) with keytool. If your path includes space-separated names, such as Program Files, use platform-appropriate notation for the names. For example, on Mac/Linux use Program\ Files, and on Windows use "Program Files". The -storetype JKS tag is only required for Java 9 or newer. As of the Java 9 release, the keystore type defaults to PKS12

1- remove upload-keystore.jks

a-  /android/app/upload-keystore.jks
b- /home/user/upload-keystore.jks

2- Regenerate file :

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storetype JKS

3- copy file /home/user/upload-keystore.jks to android/app/

4- flutter clean

5- Flutter build appbundle

Solution 4

It solves me when I remove debug.keystore from the bellow directory.

/Users/tariqul/.android/debug.keystore

Solution 5

in android folder in app folder open build.gradle and make sure to keep

(buildTypes { release { signingConfig signingConfigs.debug } })

and before prepare app bundle change it to (signingConfig signingConfigs.release)

Share:
12,989
Jason Perfetto
Author by

Jason Perfetto

Updated on June 08, 2022

Comments

  • Jason Perfetto
    Jason Perfetto almost 2 years

    I am trying to build an AAB for my flutter app. I generated the keystore using the following below command:

    keytool -genkey -v -keystore ~/pc-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias pckey
    

    I have a key.properties file, and I have referenced it using the provided code in the flutter docs. How can I solve this Java related issue? My program throws the following 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 pckey from store "/Users/jrperfetto/pc-keystore.jks": Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available