How to get NDK debugging to work in Android Studio?

与世无争的帅哥 提交于 2019-11-29 05:47:57

By the syntax of your build.gradle looks like you don't use the experimental plugin for gradle, without it you wont be able to debug native c/c++ in android studio. For more information read this : Android NDK Preview

Hong
  1. In Run->Debug Configuration "Debugger" tab, choose Debug type as "Native". In the field of "Before launch", if Android studio reports conflicts, accept the recommendation for 'fix' it. Android studio will download lldb library.

  2. click on the 'debug' bottom and wait until debugger attached to the process.

  3. now you can see the variables in the debug windown.

with LLDB installed, one has native / dual debugging available.

If you're still looking, Android Studio has recently added support for direct integration of ndk-build and CMake projects: http://tools.android.com/tech-docs/external-c-builds

Kind regards, Jomo

you can try this:

1.in app/build.gradle:

at dependencies label:

releaseCompile project(path:':youModuleName',configuration:'release')
debugCompile project(path:':youModuleName',configuration:'debug')

2.in youModule/build.gradle:

at android label:

publishNonDefault true

demo:

https://github.com/sunalong/JNIDemo

Android Studio 3

Android Studio 3 makes the whole process trivial.

To start, get your hands on a simple example app such as: https://github.com/googlesamples/android-ndk/tree/2020d9674a6601e8219eed2921f5028beb856a24/hello-gl2/

Then just set breakpoints, either on C++ or Java, and do: Run > Debug

You can also step into native calls from Java and fall in the C++ code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!