IntelliJ IDEA 14.0.0 Web Help

Generating a Signed Release APK Through an Artifact

To deploy and run an Android application on a physical device, you need to sign the application digitally. With IntelliJ IDEA, you can have your Android Application Package (.apk file) signed with an existing release key on package extraction. IntelliJ IDEA also incorporates a release key generation tool that can be invoked during the packaging procedure. Generated keys are saved in a keystore binary file.

You can have as many keystore files and keys as you need and use either existing keys, or create new ones in existing keystores, or even create new keystores.

Apart from using the Generate Signed APK Wizard, you can configure the .apk file as an artifact by creating an Android application artifact definition. When IntelliJ IDEA builds the package in accordance with this definition, the package is signed automatically.

Extracting and signing a release Android application package using an artifact definition

  1. Select File | Project structure from the main menu and click Artifacts in the left pane.
  2. Click the New button add.png and select Android Application from the context menu.
  3. In the popup menu, define the artifact contents by selecting one of the folloiwng options:
    • To create an empty layout definition, select Empty.
    • To include a module data in the artifact, select From module <module name>

    The general settings of the new artifact will be displayed in the Artifact Layout pane on the right.

  4. Specify the general settings of the artifact. In the Output directory text box, specify the location of the target package .apk file.
  5. Complete the artifact definition by following these general steps:
  6. Switch to the Android tab tab and select Release signed from the Type drop-down list.
  7. Specify the release key you want to use and the keystore file that contains it. Do one of the following:
    • To sign the package with a key from an existing keystore file:
      1. Specify the file location in the Key store path text box. Type the path manually or click the Choose existing button and select the file in the dialog that opens. In the Key store password text box, type the password to the selected keystore.
      2. Specify the key alias and enter the password to access the key.
    • To generate a new key in an existing keystore:
      1. Specify the file location in the Key store path text box. Type the path manually or click the Choose existing button and select the file in the dialog that opens. In the Key store password text box, type the password to the selected keystore.
      2. Click the Create new button and configure the release key to be generated by filling in the data in the New Key Store dialog box that opens.
    • To generate a new keystore file with a new key:
      1. Click the Create new button. In the New Key Store dialog box that opens, specify the location of the file to be generated in the Key store path text box. Type the path manually or click the Browse button browseButton.png, then select the parent folder and specify the name of the file.
      2. Specify and confirm the password to access the keystore.
      3. Configure the new release key by filling in the data in the Key area.

    Click Next.

  8. To have IntelliJ IDEA obfuscate the application during packaging, select the Run ProGuard check box and specify the location of the proguard.txt configuration file. The file is generated on project creation and is stored in the project root. IntelliJ IDEA suggests this default location in the Config file path text box. Accept the suggestion or specify a custom configuration file by clicking the Browse button browseButton.png and selecting the required file in the dialog that opens.

See Also

Last modified: 12 November 2014
comments powered by Disqus