IntelliJ IDEA 14.0.0 Web Help

Generating an APK in the Debug Mode

Apart from generating signed packages to be deployed on physical devices, or unsigned packages to be run on emulators, you can also have an application package extracted and signed in the debug mode. This signature is sufficient for testing and debugging applications, but does not allow publishing them. Signing an application package in the debug mode is available only through configuring an artifact.

In the debug mode, you can have an APK signed either with the default certificate or with a custom one.

If you decide to use the default certificate, IntelliJ IDEA signs the extracted package in the debug mode using the debug keystore or a key that is generated by the Android SDK tools and has predefined names and passwords:

  • Keystore name: debug.keystore
  • Keystore password: android
  • Key alias: androiddebugkey
  • Key password: android
  • CN (common name): CN=Android Debug,O=Android,C=US

These are the default settings in IntelliJ IDEA. This means that if you do not configure an artifact manually and select the Deploy default APK option in the Run/Debug Configuration: Android Application dialog box, IntelliJ IDEA will use the predefined values in the certificate for the generated .apk.

If you use a custom certificate, IntelliJ IDEA signs the extracted package in the debug mode using the debug keystore or a key that you specify yourself . You can have a new certificate generated or reuse an existing one. The latter approach is helpful, for example, if you have several applications and you want them all signed with he same certificate so they can be stored in the same folder on the device.

Signing a package in the debug mode

  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 and specify the certificate you want to use from the Type drop-down list:
    • Select Debug signed with default certificate to have IntelliJ IDEA use the debug keystore or a key that is generated by the Android SDK tools and has predefined names and passwords.
    • Select Debug signed with custom certificate to have the package signed with a certificate of your choice. Specify the key to use and the keystore file that contains it by doing 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.
  7. 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