15

I have an android project created by Android Studio 2.2.3 under Windows 10, this project use a native library through its wrapper jar (through JNI). The native library was built outside of Android Studio by qmake, which will use GCC 4.9 in android NDK r13b to generate the native shared library, the code was compiled with -g option.

To use this native library, I put the wrapper jar under <proj_path>/app/libs directory and the native library under <proj_path>/app/src/main/jniLibs/armeabi-v7a, everything works fine, I can successfully call the method implemented in the native library from java code.

The problem is that when I debug this android project, the breakpoint I set in the cpp file doesn't take effect, please note that the cpp file is not in the source tree of the android project, I just open it from android studio. I have installed the latest LLDB and I start debug with 'Hybrid' debug type, I also use 'image list' LLDB command to confirm that the native library image loaded when debugging is the unstripped version. But the breakpoint just won't hit.

What is wrong with my configuration?

Can somebody give me some suggestion?

Thanks!

shizhen
  • 11,455
  • 9
  • 49
  • 81
Liang Jian
  • 151
  • 5
  • Do you have some news? I think I have the same problem. I have read a ton of post about this problem and i don't found any real solution. I also posted a [question](https://stackoverflow.com/questions/46488591/how-can-i-debug-android-native-c-library-compiled-externally-with-cmake) because some days ago i didn't have the reputation to comment here. Thank you. – AndreaT Oct 05 '17 at 10:03
  • related: https://stackoverflow.com/questions/8674434/debugging-native-libraries-for-android-os/47132384 – Ciro Santilli Путлер Капут 六四事 Nov 06 '17 at 08:17
  • Android JNI debugging does not support debug native libraries, you have to enclose the C/C++ source code. – shizhen Dec 13 '18 at 05:39

1 Answers1

0

How do you expect the AndroidStudio to hit your breakpoint if your program is running over the pre-compiled code? It would be the same if you put a breakpoint in the source-code say in your Notepad++ application. Instead, you have to tell your project/code to use the source-code and not the pre-compiled lib. For this, remove all the .so files and link the source-code so NDK will compile from there.

Hack06
  • 912
  • 1
  • 11
  • 19