Build release for android not working?

I am trying to run ionic build --release android on a windows system. After build starts it stops with this:

[13:42:16] Finished ‘build:before’ after 8.31 μs

✗ You cannot run iOS unless you are on Mac OSX.

My cordova version is 6.3.0. I tried ionic state reset and npm install -g cordova. Running ionic build android works fine. Hope you can help fix this strange issue :smiley:

1 Like

I think u need a mac to compile the ios build, there was another way to compile without being on mac, im in my phone so cant find it, ill try to post the link to it.

try:

ionic build android --release

10 Likes

I am trying to compile a android build and that worked fine before. Still thanks for your time :smiley:@victorcarvalhsop: thanks it worked. Seems they changed the cli a bit.

1 Like

I think now the default goes to Ios, or at least it seems like it.

thank you!
i managed to output android-release-unsigned.apk
i submit to
https://play.google.com/apps/publish/
but there is a new error message
Upload failed
You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again.

any idea how to overcome this?
thanks!

Yes you have to zipalign the unsigned.apk to sign it first. I have a step by step guide for my environment on windows. The paths may be differ from yours.

Step 0 (only the first time):

  • run ionic platform add android (cli)

Step 1.1 (only when publishing the second and above time)

  • change version number in config.xml.

Step 1.2:

  • run “C:\program files (x86)\Java\jdk1.7.0_71\bin\keytool” -genkey -v -keystore yourAppName-release-key.keystore -alias yourAppName -keyalg RSA -keysize 2048 -validity 10000

Step 1.3:
run ionic build android --release

Step 1.4
run cd ./platforms/android/build/outputs/apk

Step 1.5:
run “C:\program files (x86)\Java\jdk1.7.0_71\bin\jarsigner” -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore yourAppName-release-key.keystore android-release-unsigned.apk yourAppName

Step 1.6:
run “C:\program files (x86)\Android\android-sdk\build-tools\23.0.3\zipalign” -v 4 android-release-unsigned.apk yourAppName.apk

Your jarsigner and zipalign tool may be in different paths than my so just find them and pass the correct path. In my case I also had to set my android environment in the cli and the correct path for the platform tools. If thats the case:

Step 2:
Run
set ANDROID_HOME=C:\program files (x86)\android\android-sdk
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

1 Like

En versiones anteriores de ionic se utitlizaba ionic build --release android para poder generar el archivo release, en versiones actualues de ionic utiliza ionic build android --release