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

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

问题描述

我使用的是Visual Studio,它的Debug机制对我来说真的很有用。在一个项目中有许多头文件和C文件,只需一个简单的F10,它可以从main()函数的开头引导我,从而可以看到执行代码的顺序。



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



我的问题是:我是寻找一种在Android Studio中逐行调试的方式,从开始查看其工作流程,喜欢Visual Studio的工作原理,但是我从搜索中获取的全部是在调试时从断点开始的方式。 >

我已经尝试将断点放在 onC中reate()启动器活动的方法,并使用 F8 Step Over F7 步入,但它不能像我预期的那样工作。它不断带我到超级类 Activity.java GLSurafaceView.java ,而不是带我到C ++代码。在Android Studio中有什么办法可以做到吗?请帮助我,谢谢高级。



我已经尝试过与其他项目,但问题仍然保持不变。希望有人可以帮助。

解决方案

这不会发生。您的应用程序(Java样板代码)设置为响应用户使用应用程序和安装该应用程序的设备时发生的许多系统事件。如果您的c ++代码是一个单一直观的算法,您可以在开始时设置s断点,并真正按照步骤进行。但是使用Android Studio,即使这个过程并不像Vusial Studio那么简单。首先,它始终是远程调试,取决于微妙的通信协议。



这说,你可以尝试设置Microsoft Visual Studio您的IDE用于调试本机Android代码。这是令人惊讶的强大,也可能比你更熟悉。


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.

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.

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.

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? Please help me, Thanks in advanced.

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

解决方案

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.

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天全站免登陆