Develop

Native Debugging with Android Studio

This section introduces debugging our sample native apps in Android Studio.
The default configurations created during project import only support Java debugging.
Select Edit Configurations… in the Configurations drop-down menu in the Android Studio toolbar.
Android Studio toolbar with the Configurations dropdown menu open.
Create a new Android App configuration as show below:
Run/Debug Configurations dialog with the add new Android App configuration option.
In the General tab of the Run/Debug Configuration dialog box, give the configuration a name and select a module.
General tab of Run/Debug Configuration dialog with name and module fields.
In the Debugger tab of the Run/Debug Configuration dialog box, change the Debug type to Native, and add symbol paths:
Debugger tab set to Native debug type with symbol search path fields.
Note that ndk-build places stripped libraries inside the libs/ directory. You must point the symbol search paths at the obj/local/<arch> directory. This is also not a recursive search path, so you must set the full path to the obj/local/armeabi-v7a directory.
Symbol path pointing to the obj/local/armeabi-v7a directory for unstripped libraries.

Troubleshooting

If you experience an application crash at AInputQueue_preDispatchEvent with SIGILL (illegal instruction), there is a workaround available by disabling the SIGILL handler in LLDB. Follow these instructions to do so:
  1. Open the application in Android Studio.
  2. Open Run > Edit Configurations.
  3. On the Run/Debug Configurations window, make sure your app is selected in the left pane, and click the Debugger tab in the right pane.
  4. On the Debugger tab, click the LLDB Post Attach Commands tab below.
  5. Click the + to the right, add the following command, and press Enter:
    process handle --pass true --stop false --notify true SIGILL
    
  6. Click OK to apply the change.