How to debug an Android Studio project (using NDK and JNI) in turn to see the workflow?

I used Visual Studio, and the Debug mechanism is very useful to me. With many headers and C files in 1 project, just plain F10, he could take a tour from the beginning of the main () function so that I can see the sequence of code being executed.

Now I go to Android Studio and start with a project using NDK, JNI (this project, for example: https://github.com/googlesamples/android-ndk/tree/master/gles3jni ), it bothers me because there are a lot of .java files and other C ++ files (native code), and I don't know what code the file is running from and how it continues.

My question is: I’m looking for a way to debug in Android Studio line by line from the very beginning to see how its workflow is like, how Visual Studio works, but all I got from the search is like starting from a breakpoint when debugging.

I tried putting a onCreate() in the onCreate() method of the launch activity and using F8 before Step Over and F7 before Step Into , but it does not work as I expect. It leads me to the superclass Activity.java and GLSurafaceView.java instead of taking me to C ++ code. Is there a way to do this in Android Studio and how to do it?

I tried with other projects, but the problem still remains the same. Hope someone can help.

+2
debugging android-studio android-ndk jni
source share
2 answers

That will not happen. Your application (Java template code) is configured to respond to many system events that occur when a user works with the application and the device on which the application is installed. If your C ++ code is part of a monolithic simple algorithm, you can set a breakpoint s at the beginning and really follow step by step. But with Android Studio, even this process is not as simple as with Vusial Studio. First, it is always remote debugging, depending on the thin communication protocols.

This suggests that you can try to configure Microsoft Visual Studio as an IDE to debug native Android code. It is surprisingly durable and may also be more familiar to you.

+1
source share

Since you asked about Android Studio, I will answer about this - I am not familiar with Visual Studio for Android and maybe better for what you ask.

In Android studio, such debugging is very difficult - although some people said that they managed to get it to work, I could not. Especially in a complex environment. So what I'm doing is extensive logging, with as much detail and visual debugging as possible - place a text view on the screen and update it with the necessary information. In some cases, this can be quite powerful. Or, alternatively, make some changes to your ui or your scene as a result of certain conditions that you define so that you can see the visual effect. Again, much less useful than debugging, but can still be quite powerful.

+1
source share

All Articles