aardvarkk aardvarkk - 5 months ago 106
Android Question

ndk-build stays at NDEBUG=1 despite Gradle debuggable: true in Android Studio

I'm having a ton of difficulty trying to get Gradle to compile a debug version of my JNI code through NDK build. I've set the debug build to be debuggable in the

file like so:

buildTypes {
debug {
debuggable true
jniDebuggable true

I can confirm that the switches are taking effect if I check out Build/Edit Build types. However, once I check the
file inside of the
directory, I notice the following entries:


I can confirm that my JNI code does not seem to be debuggable. Even though the breakpoints trigger, variables all show "variable not available" in LLVM.

Any ideas as to why NDEBUG is turned on even in a debug build? As a sidenote, I also have no idea where the android-9 platform is entering in... I'm not setting that myself anywhere that I could find.


If you use Android Studio 2.2 with externalNativeBuild, you can set APP_OPTIM=debug in your Application.mk or NDK_DEBUG=1 through parameters override, e.g.

externalNativeBuild {
  ndkBuild {
    arguments "NDK_DEBUG:=1"