Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
                                                   
like image 520
Jason Perfetto Avatar asked May 21 '21 06:05

Jason Perfetto


2 Answers

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.

like image 188
Azhar Ali Avatar answered Nov 12 '22 23:11

Azhar Ali


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
like image 46
Jason Perfetto Avatar answered Nov 13 '22 00:11

Jason Perfetto