aardvarkk aardvarkk - 1 month ago 48
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

build.gradle
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
ndkBuild_build_command.txt
file inside of the
.externalNdkBuild
directory, I notice the following entries:

NDEBUG=1
APP_PLATFORM=android-9


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.

Answer

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"
  }
} 
Comments