How to build a Ionic5/Capacitor app for release?

Hi,
this is my first app with Capacitor and I have to build this app for Android.

With Cordova I build an app with these commands:

1) ionic cordova build --prod --release android
2) cd ....myapp\platforms\android\app\build\outputs\apk\release\
3) jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myapp.keystore app-release-unsigned.apk myapp
4) zipalign -v 4 app-release-unsigned.apk MyApp-010001.apk

Now I read that with Capacitor I have to run these commands:

    - ionic build 
    - npx cap add android
    - npx cap copy android
    - npx cap open android

The last command opens Android Studio. OK

And then?
How can I:

  • sign the app? (step 3)
  • generate the apk that I have to upload on GooglePlay? (step 4)

I haven’t find a tutorial on this and I think it is strange that the Ionic site says only:
“Once Android Studio launches, you can build your app through the standard Android Studio workflow.”

Any help will be appreciated

Thank you very much

cld

1 Like

Then you can do a release build in Android Studio like a regular Android project, so you can follow the Android docs.

How to sign it depends if you have an upload key or a signing key.

1 Like

Hi,
thank you for your answer.
I’ve followed these instructions: https://www.joshmorony.com/deploying-capacitor-applications-to-android-development-distribution/
However I will read the documents of your links.
thank you

cld

Did you find a way to automate this without having to use Android Studio?

no, sorry I didn’t find it.

Bummer. This was my preferred method too. Thanks for getting back to me so quickly. It seems like such an inefficient way of doing it. Hopefully automation for multi platforms will come back again for these capacitor builds.

Hey, I found more of our answer here in the first few paragraphs. Capacitor - build cross platform apps with the web
Basically confirming no cli builds.
Cheers, Steve