Skip to content

Most visited

Recently visited


Profile and Debug Pre-built APKs

Android Studio 3.0 allows you to profile and debug APKs without having to build them from an Android Studio project. However, you need to make sure you’re using a debuggable version of the APK.

To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen. Or, if you already have a project open, click File > Profile or debug APK from the menu bar. In the next dialog window, select the APK you want to import into Android Studio and click OK. You should see something similar to figure 1.

Figure 1. Importing a pre-built APK into Android Studio.

Note: When you import an APK into Android Studio, the IDE creates a new project in your home directory and makes a local copy of the target APK. This means that if you rebuild or update the original APK, you need to manually import the updated version into Android Studio again.

The Android view in the Project pane allows you to inspect the following contents of your APK:

You can immediately use the Android profiler to start testing your app’s performance—however, the profiler currently works only with your app’s Java processes. To debug your app’s Java and native code using breakpoints, you need to first attach the Java sources and attach native debug symbols.

Attach Java sources

By default, Android Studio extracts Java code from your APK and saves them as .smali files. To debug the Java code using breakpoints, you need to attach the Java sources to each .smali file you want to debug.

To attach Java sources, proceed as follows:

  1. Double click on a .smali file from the Project pane (use the Android view). After opening the file, the editor displays a yellow warning banner asking you to select the Java sources, as shown in figure 1.
  2. Click Attach Java Sources at the top of the editor window.
  3. Navigate to the directory with the app’s Java source files and click Open.

In the Project window, the IDE replaces .smali files with their corresponding .java files. You can now add breakpoints and debug your app as you normally would.

Attach native debug symbols

If your APK includes native libraries (.so files) that don’t include debug symbols, the IDE shows you a warning in the Messages window, similar to the one shown in figure X. You can not debug the APK’s native code or use breakpoints without attaching debuggable native libraries. If you haven’t already done so, make sure to download the NDK and tools.

To attach debuggable native libraries, proceed as follows:

  1. Under the cpp directory in the Project window, double click a native library file that doesn’t include debug symbols. The editor shows a table of all the ABIs your APK supports.
  2. Click Add at the top right corner of the editor window.
  3. Navigate to the directory that includes the debuggable native libraries you want to attach and click OK.
  4. If the APK and debuggable native libraries were built using a different workstation, you need to specify local paths to the debug symbols by following these steps:
  5. Add local paths to missing debug symbols by editing the field under the Local Paths column in the Path Mappings section of the editor window, as shown in figure 2. The IDE automatically maps paths to a remote NDK to paths in your local NDK download.
  6. Click Apply.

    Figure 2. Providing paths to local debug symbols.

You should now see the native source files in the Project window. Open those native files to add breakpoints and debug your app as you normally would.

Known issue: When attaching debug symbols to an APK, both the APK and debuggable .so files must be built using the same workstation or build server.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)