3

I want to set jniDebuggable to false in Android Studio's debug version, but it seems that it doesn't work even I set like this:

    debug {
        jniDebuggable false
    }

Since my JNI debug build is slow when running, I want to use the release build (faster than debug) when I debug my Java code. Who can tell me how to do?

starball
  • 20,030
  • 7
  • 43
  • 238
Granis
  • 41
  • 1
  • I use cmake to build the jni. – Granis Sep 11 '17 at 01:52
  • You probably want to build a release version of your C++ library in the Debug configuration of your Android Studio project. This has nothing to do with isDebuggable. You can override the cmake build arguments in build.gradle script. – Alex Cohn Sep 11 '17 at 04:56
  • You can use this [answer](https://stackoverflow.com/a/45543443/192373) which is kind of reverse of your question. – Alex Cohn Sep 11 '17 at 06:01
  • 1
    Thanks, it works! – Granis Sep 13 '17 at 11:46

1 Answers1

0

As stated in the comments under the question post by @Alex Cohn, and adapted from this answer he wrote to "adding "-O0" to cppFlags fails to disable clang compile optimization in android studio", you could do:

android {
  defaultConfig {
    externalNativeBuild {
      cmake {
        arguments '-DCMAKE_BUILD_TYPE:STRING=Release'

That's if you don't need actual debug support for the native side of things (i.e. if by "debug", you really just mean running and testing your code without a debugger). If you do, use RelWithDebInfo instead of Release, which creates an optimized build with debug symbols (see here for CMake docs on build out-of-box-defined types).

See here for docs on Android NDK's CMake Guide, and here for docs on ExternalNativeBuildOptions.

starball
  • 20,030
  • 7
  • 43
  • 238