Update June 2016: In Android Studio 2.1 the default run configuration supports native debugging so there should be no need to do the below unless you're using an older version.
For older versions:
Here's how to debug native code in Android Studio:
- Go to Run->Edit configurations
- Click the + sign
- Choose 'Android Native' as the configuration type
- In the Module dropdown choose your app's module
- Add breakpoints to your C/C++ code
- Run->Debug...
The app should be deployed and the lldb
debugger will attach after ~10s.
Note: When creating the debug configuration under the 'Native Debugger' section you can choose gdb
, however this is less well supported than lldb
and known to be buggy. Use at your own risk.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…