如何让 NDK 调试在 Android Studio 中工作? [英] How to get NDK debugging to work in Android Studio?

查看:28
本文介绍了如何让 NDK 调试在 Android Studio 中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio 不会在 C++ 代码中的断点处停止,这就是我目前所做的:

Android Studio doesn't stop at breakpoints in C++ code, this is what i've done so far :

  1. 在 AndroidManifest.xml 中:

  1. In AndroidManifest.xml :

android:debuggable="true"

  • 在 build.gradle 中(这可能是问题所在):

  • In build.gradle (this may be the problem):

    sourceSets.main {
      jniLibs.srcDir 'src/main/libs'
      jni.srcDirs = []
    }
    
    task ndkBuild(type: Exec) {
      commandLine android.ndkDirectory.getAbsolutePath() + '\\' + 'ndk-build.cmd', '-C', file('src/main/jni').absolutePath, 'NDK_DEBUG=1'
    }
    
    tasks.withType(JavaCompile) {
      compileTask -> compileTask.dependsOn ndkBuild
    }
    

    1. 将应用程序配置为 Android Studio 上的本机应用程序

    1. Configured the application as a native application on Android Studio

    在 C++ 代码中放置断点

    Put breakpoints in C++ code

    调试应用

  • 这似乎有效,因为它说:现在启动本机调试会话"而且我可以使用停止按钮暂停应用程序但没有断点工作.

    This seems to work because it is saying : "Now Launching Native Debug Session" moreover I can pause the app with the stop button but no breakpoint is working.

    感谢您的帮助

    推荐答案

    根据你的 build.gradle 的语法看起来你没有使用 gradle 的实验插件,没有它,您将无法在 android studio 中调试本机 c/c++.有关更多信息,请阅读:Android NDK 预览

    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

    这篇关于如何让 NDK 调试在 Android Studio 中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆