Publishing ionic app

what is zipalign?
how can l zipalign my apk file
ionic docs says something like this
{
This signs the apk in place. Finally, we need to run the zip align tool to optimize the APK. The zipalign tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign. For example, on OS X with Android Studio installed, zipalign is in ~/Library/Android/sdk/build-tools/VERSION/zipalign:
$ zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

}
but l dont understand the process of setting up zipalign.
l hav android studio installed

The zipalign tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign.

http://ionicframework.com/docs/guide/publishing.html

To generate a release build for Android, we can use the following cordova cli command:

$ cordova build --release android
This will generate a release build based on the settings in your config.xml. Your Ionic app will have preset default values in this file, but if you need to customize how your app is built, you can edit this file to fit your preferences. Check out the config.xml file documentation for more information.

Next, we can find our unsigned APK file in platforms/android/build/outputs/apk. In our example, the file was platforms/android/build/outputs/apk/HelloWorld-release-unsigned.apk. Now, we need to sign the unsigned APK and run an alignment utility on it to optimize it and prepare it for the app store. If you already have a signing key, skip these steps and use that one instead.

Let’s generate our private key using the keytool command that comes with the JDK. If this tool isn’t found, refer to the installation guide:

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
You’ll first be prompted to create a password for the keystore. Then, answer the rest of the nice tools’s questions and when it’s all done, you should have a file called my-release-key.keystore created in the current directory.

Note: Make sure to save this file somewhere safe, if you lose it you won’t be able to submit updates to your app!

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
This signs the apk in place. Finally, we need to run the zip align tool to optimize the APK. The zipalign tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign. For example, on OS X with Android Studio installed, zipalign is in ~/Library/Android/sdk/build-tools/VERSION/zipalign:

$ zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
Now we have our final release binary called HelloWorld.apk and we can release this on the Google Play Store for all the world to enjoy!

(There are a few other ways to sign APKs. Refer to the official Android App Signing documentation for more information.)

I feel your pain, I had trouble with this, I was so close to publishing my first app then I got thrown this curveball!

You don’t really need to ‘set up’ zipalign, you just need to run the tool on your signed APK file before it will be allowed into the Android store.

I’m assuming you are using the command line if you have got this far…I had trouble using the zipalign tool until i added the full path so try this -

From the command line

  • cd into your project's ionic directory that has the apk file ($ cd myAppFolder/platforms......etc) then run
  • $ /Users/yourUserName/Library/Android/sdk/build-tools/22.0.1/zipalign zipalign -v 4 *yourapkname-release-unsigned.apk* *HelloWorld*.apk
  • You should then see the new APK file in the project folder.

    Note that you will need to make sure the path to zipalign is correct (easiest way is to navigate to it via Finder and drag into command line. If you can’t see the library folder in Finder then search google for how to show this, depends on what version of OS you are on.)

  • 1 Like

    Here you have a related post i wrote. feel free to contact me i you have any further question. Tutorial: how to generate release APK for GooglePlay (signed and aligned)

    trying it out, thanks

    kk…trying it out …ok

    1 Like

    try it https://blog.icool.io/ionic-framework-app-development-tips-and-tricks/

    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.

    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.

    am using windows pc

    how do l run /Users/yourUserName/Library/Android/sdk/build-tools/22.0.1/zipalign

    getting this error

    C:\app\rmu\platforms\android\build\outputs\apk>/Users/mit/AppData/Local/Android/sdk/build-tools/21.1.2
    ’/Users/mit/AppData/Local/Android/sdk/build-tools/21.1.2’ is not recognized as an internal or external command, operable program or batch file.

    You’re on Windows, NooNoo indicated a OSX path, you have to adapt it to your OS and the folder where you installed the Anrdoid SDK.

    1 Like

    So i used the command as described, but the apk does not get created, instead i get zip align information…

    /Users/xxx/Library/Android/sdk/build-tools/23.0.2/zipalign zipalign -v 4 android-release-unsigned.apk eitc.apk
    Zip alignment utility
    Copyright © 2009 The Android Open Source Project

    Usage: zipalign [-f] [-p] [-v] [-z] infile.zip outfile.zip
    zipalign -c [-v] infile.zip

    : alignment in bytes, e.g. ‘4’ provides 32-bit alignment
    -c: check alignment only (does not modify file)
    -f: overwrite existing outfile.zip
    -p: page align stored shared object files
    -v: verbose output
    -z: recompress using Zopfli

    Are you running the command in the folder that has the android-release-unsigned.apk file?

    Yes, I am running it in that folder itself.