Tutorial: how to generate release APK for GooglePlay (signed and aligned)

It requires installing “Android Studio” with “SDK manager”. “Java SDK” and set the “PATH” system indicating the route to both.
Where it says appname put the name of your app :smirk: .
This tutorial is valid for MAC, I have not tested on WIN or Linux but I guess it is the same.

1.    Remove console development: cordova plugin rm org.apache.cordova.console.
2.    Generate apk:  `cordova build android --release` .  You create the file  android-release-unsigned.apk  in the folder: appfolder/platforms/android/build/outputs/apk/
3.    Generate Key:  `keytool -genkey -v -keystore appname-key.keystore -alias appname -keyalg RSA -keysize 2048 -validity 10000`   it generate file   appname-key.keystore
4.   Remember to record the key used to generate the key 
5.       Copy file in the same folder as the  Step 2:  appfolder/platforms/android/build/outputs/apk/
6.    Move to the previous directory and run  `jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore appname-key.keystore android-release-unsigned.apk appname`
7.    Align apk:  `zipalign -v 4 android-release-unsigned.apk appname.apk`
8.    It generate valid apk  with the name: appname.apk
9.    Upload to Google Play first as  Beta later promote to  Prod.

I hope you find it useful

7 Likes

Thanks man! :+1: :+1:

Hi @SoyJulen ,

I zipalign my app in C:\Program Files (x86)\Android\android-sdk\build-tools\21.0.0 directory… It says verification success full… Where will be the apk will store now.

Thankyou

still having problems with zipalign

C:\app\rmu\platforms\android\build\outputs>zipalign -v 4 android-release-unsigne
d.apk rmu.apk
’zipalign’ is not recognized as an internal or external command,
operable program or batch file.

Hi karthik123 sorry for the late response. It should be allocated on the same directory, if not try looking on /platforms/android/build/outputs/apk/.

It seems like you don’t have Android Studio installed on your computer. If its allready installed you have to Setting ANDROID_HOME Environmental Variable.

Hi @tenison201. Zip align command should use in “C:\Program Files (x86)\Android\android-sdk\build-tools\21.0.0” directory…

Hi @SoyJulen … Thankyou for your response…

sorry for the late response!!! thanks l got it

Thanks!!! got it… :joy:

Hey there, i’m trying to get a key

It’s all going well, i have my android-release-unsigned.apk get into the project, start the keytool -genkey command

then enter all my details (name and such) then, when it asks for confirmations, showing me my key details, i only get a [no]: …

I tried everything, Y, y, enter… etc but it’s always asking me again my details and doesn’t generate any key, it’s looping over and over again over my details when i press enter

Is this a bug or am i doing something wrong ? is there a super secret command to generate the key ??? Thanx in advance (im on OSX)

hi, when i try jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name i get the error jarsigner cannot be recognised as an internal or external command. i’ve added C:\Program Files (x86)\Java\jre1.8.0_73\bin; to the environment variables which is how keytool worked but i dont understand why it is not working now

@Amisha3one5 you should add the jdk\bin location point not jre\bin location point

amigos tengo mucho tiempo tratando de generar mi apk para android y no e logrado hacerlo, ya e intentado muchos métodos e incluso tengo lo requerido en este tutorial y las variables en el PATH, sera q pueden darme una referencia de algún vídeo o foro en el cual pueda ver mas a fondo y solucionar los errores o si no es mucha molestia q uno de ustedes me preste la ayuda necesaria para configurar bien el ámbito de trabajo y que pueda generar apks de manera exitosa?
Gracias!

@LuiisMS adjunta alguna captura de pantalla o mensaje de error para que te podamos ayudar. Cuéntanos si estás en Windows, Linux o Mac y que versión de Ionic estás usando.

1 Like

amigo, gracias dios pude solucionar mi problema, para lo que tengan alguna pregunta sobre lo q andaba buscando, puede preguntarme y sabre responder tambien para que puedan generar su apk de forma exitosa asi como ya pude hacerlo!!
gracias x la pronta respuesta y pues estaré atento porque soy nuevo en este mundo ionico y necesitare de mucha ayuda, ya que estoy construyendo una app para mi proyecto de ingenieria como ya lo dije y es sencillo, pero para mi un poco dificil por ser nuevo!!
SALUDOS (Y)