I am developing android app using NDK. I have two projects. One is for my native library which uses NDK and generates .so file.
I am using Android Studio but disabli
In Android Studio 2.0 preview the process is a bit different (ans easier I think):
If it doesn't work, check that your native configuration has debug type "Hybrid" selected: On the right of the play button, click the little triangle, select "Edit Configurations", select your "app-native" configuration, go in the "Debugger" tab and select "Debug type: Hybrid".
Android Studio 1.3+ supports native debugging.
To set it up, follow these steps:
- Modify your gradle-wrapper.properties, local.properties, and both build.gradle files as shown in this guide
- Sync gradle
Create and select new build configuration:
Click on drop down next to run button) -> Edit configurations, click plus sign, choose Android Native, fill in options on the right (I used LLDB in native debugger tab), and you should be set.
Set breakpoints in C++
- Hit debug button and be patient (sometimes the debugger takes a while)
I have been able to debug native code under Lubuntu 14.04 with Android Studio 1.3 (stable channel). Although others have supposedly been successful under Windows, I haven't been able to debug natively in Windows 8.1 (I have tried with Android Studio 1.3, 1.3.2, and 1.4 preview 3).
Update Android Studio 1.4 Beta just came out. I tested it and was able to debug natively on Windows 8.1.
If your native breakpoint still can't get hit after you tried everything AND by any chance your native library had been referenced across multiple AS projects, then there is a simple solution.
Just rename your native library in setting.gradle and your build.gradle
Befor:
//in setting.gradle
include ":myNativeLib"
project(":myNativeLib").projectDir = new File("...")
//in app's build.gradle
api project(':myNativeLib')
After:
//in setting.gradle
include ":myNativeLib2"
project(":myNativeLib2").projectDir = new File("...")
//in app's build.gradle
api project(':myNativeLib2')
Another check point if breakpoints in native codes don't work:
android:extractNativeLibs="false"
line or set it true in AndroidManifest.xmlextractNativeLibs="false"
causes 1 or 2, occasionally.
I was able to set breakpoints and step into native code but only when all of the following were true:
It is working for me right now in Android Studio 1.5, using the Gradle Experimental Plugin