在 Android Studio(v4.1.2) 中尝试 ndk-build C 代码调试。下面是 build.gradle 设置。
jni , C/C++ 源文件 Dirs. 实际的 C 文件不在 jni 文件夹下,而是在它之外,但在 android.mk 文件中引用。
sourceSets.main.jniLibs.srcDirs = ['D:/ccodefolder/jni/']
2)Android.mk 从 C、c++ 代码构建一个共享库,并链接内置的共享库和静态库。
externalNativeBuild {
ndkBuild {
path file('D:/ccodefolder/jni/Android.mk')
}
}
ndkVersion '21.1.6352462'
debug {
debuggable true
jniDebuggable true
minifyEnabled false
shrinkResources false
//ndk.debugSymbolLevel = 'FULL'
}
4) 项目结构如图所示。
能够运行项目并生成共享库以及其他预构建的 .SO 和 apk 作品,还创建了 CPP 文件夹并能够查看我的项目的 C 代码文件。
调试问题:
LLDB 服务器启动并且调试器附加到进程,但调试任何 C 文件失败并出现以下错误。
断点当前不会被命中。没有可执行代码与此行相关联
谢谢