Reputation: 390
I want to debug native code in Android Studio (version 2.2) in following examples: https://github.com/googlesamples/android-ndk/tree/master-ndkbuild.
I have tried to edit app Run/Debug configuration and change debugger type to native or hybrid without success. Also tried to attach debuger selecting hybrid or native, but app doesn't stop on breakpoint in C++ code, when debugger is connected to process.
I have bigger project which is built simillary to linked examples. Currently rebuilding makefiles is not possible, therefore I want to run debugging with this kind or project setup. This kind of project setup means; using externalNativeBuild with ndk-build.
Does anyone know how to debug these examples?
Upvotes: 1
Views: 3751
Reputation: 548
In application's build.gradle
:
buildTypes {
debug {
debuggable true
initWith debug
jniDebuggable true
externalNativeBuild {
ndkBuild {
cFlags "-DDEBUG=1"
}
}
}
}
cFlags
is optional, but useful. It's not described in official Google docs, i found it in Android Gradle plugin DSL docs
Works on Android Studio 2.2.2+
Upvotes: 1
Reputation: 390
Unfortunetly AS + gradle + ndk-build doesn't support debugging from IDE. The solution is to rewrite buildscripts to cmake.
Upvotes: 0