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

问题描述

Android的Studio不会在C ++ code断点处停止,这是我到目前为止已经完成的:


  1. 在AndroidManifest.xml中:

     的android:可调试=真


  2. 在的build.gradle(这可能是问题):

      sourceSets.main {
      jniLibs.srcDir'的src / main /库
      jni.srcDirs = []
    }任务ndkBuild(类型:执行){
      命令行android.ndkDirectory.getAbsolutePath()+'\\\\'+'NDK-build.cmd','-C',文件('的src / main / JNI')。absolutePath,'NDK_DEBUG = 1'
    }tasks.withType(JavaCompile){
      compileTask - > compileTask.dependsOn ndkBuild
    }


  3. 配置的应用程序在Android工作室的本地应用程序


  4. 将断点在C code


  5. 调试应用程序



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

感谢您的帮助。


解决方案

你的build.gradle的语法看起来你不使用的,
没有它,你将无法调试本地C / C ++在Android Studio中。
欲了解更多信息,请阅读本:

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

  1. In AndroidManifest.xml :

    android:debuggable="true"
    

  2. 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. Configured the application as a native application on Android Studio

    2. Put breakpoints in C++ code

    3. Debug the app

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.

Thank you for your help

解决方案

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中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:03