Build Android app in Release Mode

  Options

Build Android app in Release Mode

Important

It is important to note that, when you are ready to release your application for end-users, you must sign it with a suitable private key. You cannot publish an application that is signed with the debug key generated by the SDK tools. For more details about the Android signing process refer Android documentation.

When your application is ready for release to other users, you must:

  • Obtain a suitable private key

  • Compile the application in release mode

  1. Obtain a suitable private key

    In preparation for signing your application, you must first ensure that you have a suitable private key with which to sign. A suitable private key is one that:

    • Is in your possession

    • Represents the personal, corporate, or organizational entity to be identified with the application

    • Has a validity period that exceeds the expected lifespan of the application or application suite. A validity period of more than 25 years is recommended.

    • Is not the debug key generated by the Android SDK tools.

    The key may be self-signed. If you do not have a suitable key, you must generate one using Keytool. Make sure that you have Keytool available, as described in Basic Setup. Here's an example of a Keytool command that generates a private key:

    $ keytool -genkey -v -keystore my-release-key.keystore

    -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

    Running the example command above, Keytool prompts you to provide passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. For more details about key generating refer to Android documentaion Or keytools documentaion

  2. Compile the application in release mode

    To specify your keystore and alias, open the project ant.properties file (found in the root of the project directory Ex:mobile/android/output-dir ) and add entries for key.store and key.alias. For example:

    key.store=path/to/my.keystore

    key.alias=mykeystore

    1. Open a command-line and navigate to the root of your project directory (Ex: $ /path/to/my_new_cordova_project ).

    2. Use Ant to compile your project in release mode:

      $ ant release

    3. When prompted, enter you keystore and alias passwords.

    This creates your Android application .apk file inside the project bin/ directory, named your_project_name-release.apk. This .apk file has been signed with the private key specified in ant.properties. It's ready for installation and distribution.