dilluns, 24 d’abril del 2017

Ionic 2, publishing your app. Android

Finally the app development has finished and it is time to publish it. Here you can find more documentation about the process.

If we have run the command ionic platform add android inside the project directory we can find a platforms directory. In platforms/android/build/outputs/apk we will find the result of this process.

First, we edit the config.xml file and modify  the id and version attribute in the widget tag, and the tags name, description and author. Then we run the command in a terminal inside our project directory.

   ionic build --release --prod android

If appears an error with this message

   Error: No Java files found that extend CordovaActivity

Then for solve it we run

   ionic platform rm android
   ionic platform add android

And now we run the first command again. If all the process it will well a BUILD SUCCESSFULL message appears and the route to the apk file.

   platforms/android/build/outputs/apk/android-release-unsigned.apk

Now we can sign the apk file. For that we need a private key, I assume you already have one if it is not so, you will have to create one using keytool.

   keytool -genkey -v -keystore your-release-key.keystore -alias 
          your_alias_name -keyalg RSA -keysize 2048 -validity 10000

The next step is run jarsigner to sign the apk

   jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 
             -keystore your-release-key.keystore 
             android-release-unsigned.apk your_alias_name

And finally the last step is optimize the apk using the zipalign tool.  The tool can be find in /path/to/Android/sdk/build-tools/VERSION/zipalign. In my case using OS X, I run 

   ~/Library/Android/sdk/build-tools/25.0.2/zipalign
             -v 4 android-release-unsigned.apk myApp.apk

And now, our app is ready to be published in Google Play. And remember, every time that the app is updated, you have to modify the config.xml file and update the version attribute before creating the apk.

Cap comentari:

Publica un comentari a l'entrada