Sign an apk file

Hi,
I generated an apk file for my project, but when I wanted to put it in “Play Store”. I did not manage to do it, because a problem of signature!

These are the instructions I made:

1) keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias

2) jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks app-unsigned.apk my-alias

3) /Users/mac/Library/Android/sdk/build-tools/28.0.2/zipalign -v 4 app-unsigned.apk app-signed.apk

4) /Users/mac/Library/Android/sdk/build-tools/28.0.2/apksigner verify app-signed.apk

The first 3 commands give a message of success operation, but the last one give this error:

DOES NOT VERIFY
ERROR: JAR signer CERT.RSA: JAR signature META-INF/CERT.SF indicates the APK is signed using APK Signature Scheme v2 but no such signature was found. Signature stripped?

On the other hand, i used Android Studio to generate the app file signed, but i take an other error type :

Error:Android Source Generator: Error: Can’t find bundle for base name messages.AndroidJpsBundle, locale fr_FR
java.util.MissingResourceException:

Can you tell me why this problem !! thank you in advance.

Hi @AminePro

This is what I did and these steps worked for me

First run this command

ionic cordova build android --prod --release

  1. keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Following steps should be done in the folder where your apk resides
(path : platforms/android/app/build/outputs/apk/release )

2. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name

3. zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

if your keyfile is in root then the 2nd step command will be something like this

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../../../../../../../my-release-key.keystore HelloWorld-release-unsigned.apk alias_name

Thank you very much, i think that this is the same solution! because i solved this problem before seeing your answer. A friend gave me this link where i found the solution :

https://ionicframework.com/docs/v1/guide/publishing.html

I think that the problem was in the file that i didn’t generate it correctly in first.