IntelliJ IDEA 14.0.0 Web Help

Running and Debugging Android Applications

On this page:

Running or debugging an entire Android application

  1. Start creating an Android run/debug configuration.
  2. On the Run/Debug Configuration: Android page that opens, specify the configuration name and select the module to which this configuration will be applied.
  3. Choose the Deploy default APK option in the Package area and Launch default Activity in the Activity area. IntelliJ IDEA will upload the .apk built from the module specified in the Module drop-down list above. The .apk is built automatically, no preliminary artifact configuration is required from your side.
  4. Appoint the device where the application will run:
    • To use a virtual device, select the Emulator option in the Target Device area, choose an emulator from the drop-down list or create a new one.
    • To use a physical device, select the USB device option in the Target Device area and plug-in the device through a USB cable.
  5. Start running or debugging the target activity. If you have not specified a target device, choose it manually.
  6. View and analyze Android system messages in the Logcat tab of the Android tool window.

Running or debugging a custom .apk that will be later embedded in an application

  1. Configure an artifact to generate the .apk from:
    • In the main menu, navigate to File | Project Structure .
    • In the left-hand pane, click Artifacts. In the central pane, click the Add button add in the toolbar.
    • Select Android Application from the list of available artifact types and then select Empty from the context menu.
    • In the right-hand pane, add the artifact compoenents. The artifact must contain all resources and code that want packaged in the .apk. For details, refer to Generating a Signed Release APK Through an Artifact and Configuring Artifacts.
  2. Start creating an Android run/debug configuration.
  3. On the Run/Debug Configuration: Android page that opens, specify the configuration name and select the module to which this configuration will be applied.
  4. To run or debug a custom .apk, choose the Deploy custom artifact option in the Package area and select the artifact to build the .apk from. In this case, you have to define the artifact manually before creating a run/debug configuration (see Generating a Signed Release APK Through an Artifact and Configuring Artifacts for details). Then select the Launch option in the Activity area and specify the start-up activity from the chosen artifact (.apk). Type the activity name manually or click the Browse button browseButton.png and select it in the Select Activity Class dialog box that opens.

    The list of available activities is determined by the choice of the module.

  5. Appoint the device where the application will run:
    • To use a virtual device, select the Emulator option in the Target Device area, choose an emulator from the drop-down list or create a new one.
    • To use a physical device, select the USB device option in the Target Device area and plug-in the device through a USB cable.
  6. Start running or debugging the target activity. If you have not specified a target device, choose it manually.
  7. View and analyze Android system messages in the Logcat tab of the Android tool window.

Debugging an already running application

To attach the debugger to a running process

  1. In the Android Layout Preview Tool Window or in the Android Designer Tool Window, click the Attach debugger to Android process button addAndroidDebuggerToProcess in the toolbar.
  2. In the Choose Process dialog that opens, select a process from the list that shows all currently active processes grouped by the devices where they are running.

To apply a run/debug configuration without deploying a package or launching an activity

  1. Start creating an Android run/debug configuration. On the Run/Debug Configuration: Android page that opens, specify the configuration name and select the module to which this configuration will be applied.
  2. Select the Do not deploy anything option in the Package area and Do not launch Activity in the Activity area.
  3. Appoint the device where the application will run:
    • To use a virtual device, select the Emulator option in the Target Device area, choose an emulator from the drop-down list or create a new one.
    • To use a physical device, select the USB device option in the Target Device area and plug-in the device through a USB cable.
  4. Start running or debugging the target activity. If you have not specified a target device, choose it manually.
  5. View and analyze Android system messages in the Logcat tab of the Android tool window.

In this section

See Also

Last modified: 12 November 2014
comments powered by Disqus