Android Studio 是否支持 JNI 调试?
Does Android Studio support JNI debugging?
我想调试用C 编写的代码。目前,AndroidStudio 1.2.2 似乎不支持JNI 调试。
Android Studio 1.3 RC 1 版本是否支持单步执行,作为 Java 调试器单步执行?
Android Studio 首次使用 1.3 RC 1 支持 JNI 调试。参见 here
要开始使用此功能,请转至 add native code。
使用新的 Android Studio 1.3 预览版 C++ 集成检查 this repository Android NDK 样本。
支持,但有限制。
Limitations
First, the Android NDK support only works with the new experimental Gradle plugin for Android (which in turn requires Gradle 2.5).
While the new gradle plugin delivers some major performance improvements (and Android NDK build support), note that it also requires changes to the build file “DSL” (the way your build is described in your build.gradle files.) Not only will you need to modify your build.gradle files (a process we hope to automate before the plugin graduates from experimental to stable), but we anticipate making some additional incompatible changes along the way.
Second, note also that Android Studio has not yet been updated to fully handle the experimental plugin. This means that for example the Project Structure Dialog, and various quick fixes which automatically update the build data, do not work correctly. You’ll need to edit your build.gradle files manually to configure your projects. As another example, the various templates which update the build files (such as New Module), have not yet been updated.
Finally, there are still some known bugs in this build; when debugging with LLDB breakpoints do not always work on Windows; if you run into this, you can switch to GDB debugging as a temporary workaround.
如果您的本机代码被包装为一个库,您需要将此部分添加到您的 应用程序的 gradle:
model {
android.sources {
main {
jniLibs {
dependencies {
project ":mynativelib" buildType "debug"
}
}
}
}
我想调试用C 编写的代码。目前,AndroidStudio 1.2.2 似乎不支持JNI 调试。 Android Studio 1.3 RC 1 版本是否支持单步执行,作为 Java 调试器单步执行?
Android Studio 首次使用 1.3 RC 1 支持 JNI 调试。参见 here
要开始使用此功能,请转至 add native code。
使用新的 Android Studio 1.3 预览版 C++ 集成检查 this repository Android NDK 样本。
支持,但有限制。
Limitations
First, the Android NDK support only works with the new experimental Gradle plugin for Android (which in turn requires Gradle 2.5).
While the new gradle plugin delivers some major performance improvements (and Android NDK build support), note that it also requires changes to the build file “DSL” (the way your build is described in your build.gradle files.) Not only will you need to modify your build.gradle files (a process we hope to automate before the plugin graduates from experimental to stable), but we anticipate making some additional incompatible changes along the way.
Second, note also that Android Studio has not yet been updated to fully handle the experimental plugin. This means that for example the Project Structure Dialog, and various quick fixes which automatically update the build data, do not work correctly. You’ll need to edit your build.gradle files manually to configure your projects. As another example, the various templates which update the build files (such as New Module), have not yet been updated.
Finally, there are still some known bugs in this build; when debugging with LLDB breakpoints do not always work on Windows; if you run into this, you can switch to GDB debugging as a temporary workaround.
如果您的本机代码被包装为一个库,您需要将此部分添加到您的 应用程序的 gradle:
model {
android.sources {
main {
jniLibs {
dependencies {
project ":mynativelib" buildType "debug"
}
}
}
}