如何逐行调试Android Studio Project(使用NDK和JNI)查看工作流程? [英] How to debug Android Studio Project (using NDK and JNI) line by line to see the workflow?

查看:26
本文介绍了如何逐行调试Android Studio Project(使用NDK和JNI)查看工作流程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Visual Studio,它的调试机制对我非常有用.在 1 个项目中有许多头文件和 C 文件,只需一个简单的 F10 就可以带我从 main() 函数的开始处浏览一遍,以便我可以看到正在执行的代码的顺序.

I was using Visual Studio and it's Debug mechanism is really useful to me. With many header and C files in 1 project, just a simple F10 it could take me a tour around from the beginning of the main() function so that I could see the sequence of the code being executed.

现在我要进入 Android Studio 并从一个使用 NDK、JNI 的项目开始(这个项目例如:https://github.com/googlesamples/android-ndk/tree/master/gles3jni),这让我很困惑,因为有很多 .java 文件和其他 C++(原生code) 文件,我不知道首先执行哪个文件中的哪个代码以及它是如何进行的.

Now I'm jumping into Android Studio and start with a project using NDK, JNI (this project for example: https://github.com/googlesamples/android-ndk/tree/master/gles3jni), it makes me confused because there're many .java files and others C++ (native code) files and I don't know which code from which file is executed first and how it goes on.

我的问题是:我正在寻找一种从头开始在 Android Studio 中逐行调试的方法查看其工作流程 喜欢 Visual Studio 的工作方式,但我从搜索中得到的只是如何调试时从断点开始.

My Question is: I'm looking for a way to debug in Android Studio line by line from the beginning to see its workflow likes how Visual Studio did but all I got from searching is how to start from a breakpoint when debugging.

我尝试将断点放在启动器活动的 onCreate() 方法中,并使用 F8Step Over>F7Step Into 但它不像我期望的那样工作.它一直把我带到超类 Activity.javaGLSurafaceView.java 而不是把我带到 C++ 代码.在 Android Studio 中有什么方法可以做到这一点以及如何做到这一点?

I have tried putting the break point in the onCreate() method of the launcher activity and use F8 to Step Over and F7 to Step Into but it doesn't work as i expect. It keeps taking me to the super class Activity.java and GLSurafaceView.java instead of taking me to the C++ code. Is there any way to do so in Android Studio and how to do it?

我已经尝试过其他项目,但问题仍然存在.希望有人能帮忙.

I have tried with others project but the problem still remain the same. Hope someone could help.

推荐答案

这不会发生.您的应用程序(Java 样板代码)设置为响应用户使用应用程序和安装应用程序的设备时发生的许多系统事件.如果你的c++代码是一个单一的直截了当的算法,你可以在开头设置s断点,真正一步一步来.但是对于 Android Studio,即使是这个过程也不像 Vusial Studio 那样容易.首先,它总是远程调试,依赖于微妙的通信协议.

This won't happen. Your app (the Java boilerplate code) is set to respond to many system events that happen when the user works with the app and the device on which the app is installed. If your c++ code is a piece of monolythic straightforward algorithm, you can set s breakpoint in the beginning and really follow step by step. But with Android Studio, even this process is not as easy as with Vusial Studio. To begin with, it's always remote debugging, dependent on delicate communication protocols.

这就是说,您可以尝试将 Microsoft Visual Studio 设置为用于调试原生 Android 代码的 IDE.它非常强大,而且您可能更熟悉.

This said, you can try to set up Microsoft Visual Studio as your IDE for debugging native Android code. It is surprisingly robust, and also may be more familiar to you.

这篇关于如何逐行调试Android Studio Project(使用NDK和JNI)查看工作流程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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