2

I have generated the apk using the command:

ionic cordova build android --prod --release

after that I have generated the key for Play Store using the command:

keytool -genkey -v -keystore myapp-release-key.keystore -alias com.exel.myapp -keyalg RSA -keysize 2048 -validity 10000

later I have signed using jarsigner command:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myapp-release-key.keystore platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk com.exel.myapp

finally I am bundling using Zipalign with this command:

C:\Users\Exel\AppData\Local\Android\sdk\build-tools\29.0.0\zipalign -v 4 platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk myapp-release-signed.apk

When I am uploading the app to the Play Store it’s giving a warning like unoptimized code “please bundle using an Android app bundle”.

So, I need suggestions and solutions for this problem. I will be very thankful for this forum if I can fix this with your help.

When I am trying to do an Android apk/bundle using an Android Studio 3.4.1 it’s giving me a warning like “Android Gradle Plugin version should be 3.2 or higher”. When I am clicking the update button it’s getting dismissed and continuously showing the same message every time.

“Android Gradle Plugin version should be 3.2 or higher”.

Oriol Roma
  • 329
  • 1
  • 5
  • 9
Subodh Singh
  • 21
  • 1
  • 3

2 Answers2

1

If you are missing one step, try this. I am using this command to build a release app:

To generate Keystore file:

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

Build android

ionic cordova build android --prod --release

To sign the unsigned APK, run the jarsigner tool which is also included in the JDK:

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

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

apksigner verify exercisetips.apk

In the above command you are not using this one:

jarsigner -verify -verbose -certs C:\ionic\myapp\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk

Let me know if it's works for you or not. Hope it helps you :)

user9088454
  • 1,076
  • 1
  • 15
  • 45
  • Thanks mate, this one helps a lot! – MisterMonk Aug 13 '20 at 10:10
  • I upgraded to plaftorm android 10.1.2 from 7.0.0 and now it's using gradle and produces .AAB file How can I tell the build command (cordova build android --release -- --keystore="..." --storePassword= ....) to produce .apk in addition to the .aab ? I don't care to publish on Google Play. thank you. – Meryan May 07 '22 at 08:38
  • there is no issue in .AAB file, play store let you upload file. – user9088454 May 07 '22 at 09:35
0

The most straight forward way is always command line scripts... This is the sequence of steps to prepare deploy to production an optimized bundle.

  1. create package
    ionic cordova build android --prod --release
  2. build app bundle (optimization) KEY STEP
    cd [YOUR_PROJECT_FOLDER_PATH]\platforms\android
    gradlew.bat bundle
  3. sign the app bundle
    cd [YOUR_PROJECT_FOLDER_PATH]\platforms\android\app\build\outputs\bundle\release
    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "[YOUR_certificate-keys.jks_FILE_PATH]" app-release.aab [YOUR_NAME] -storepass [YOUR_CERTIFICATE_PASSWORD]
  4. Just upload your boundle (*.aab) YOUR_PROJECT_FOLDER_PATH\platforms\android\app\build\outputs\bundle\release\app-release.aab
Market
  • 450
  • 6
  • 17