Help: Android Templates compilation to obtain .cpp lines in the call stack

Godot Version

4.2.1

Question

How can I compile the Android Templates so to obtain in the call stack (I get the call stack with the adb logcat command) also the .cpp lines and not only the .java/.kt ones?

Can you also post an example? At the moment I don’t know what you mean, are you trying to debug an error? You can’t debug native code with adb (i think)

  • In the Run/Debug Configurations window, select the editor entry, and under Debugger make sure the Debug Type is set to Dual (Java + Native)

‐----‐----‐–‐‐-----------------‐--------

Debug your app  |  Android Studio  |  Android Developers.

If you add C and C++ code to your project, Android Studio also runs the LLDB debugger in the Debug window to debug your native code.

Let me explain my problem.
I think to have found a bug on GLES3 Godot 4 rendering for Android that crashes the game at rendering initialization, but the adb logcat show the crash call stack of the only java/kotlin sources. I need to can get the .cpp sources lines too, because I think the bug could be located in the cpp section that is called from the java one.

java.lang.IllegalStateException: Unable to initialize engine render view ?

I think I can also reproduce this error on my old smartphone.

(When I try to debug with Android Studio I get other errors, ‘armeabi-v7a’ I may not have configured properly yet. )

Yes, it is, also if sometime it is:
java.lang.IllegalStateException: Unable to initialize engine native layer

but I think could be the same bug (or similar).

Can you help me to use Android Studio to debug it, please? :slight_smile:

This error could be because this architecture is disabled in the Export Settings, try to simple enable it.

yes i could try to debug it, without Exception , but with a breakpoint (Android Studio)

On my Samsung Tab S7, Godot C++ sources are not executed

adb logcat > logs.txt (press Ctrl + C to cancel)

you could redirect all logcat outputs to a text file, maybe I will understand the problem better.

Can you explain to me how I can use the Godot sources to debug the compiled .APK from Android Studio?

I haven’t tried that yet, but it should also work, maybe like this: Debug pre-built APKs

If you want to debug the Godot sources, you should find almost everything here.
Android Studio - Importing the project

If you get stuck, let me know. So far, I have set up the development environment under MacOS. (I also know my way around Windows.)

Thanks a lot, I’ll try ASAP.

I’m just working with it, really powerful. Thanks a lot! :wink:

1 Like

I think yesterday I executed the debugger incorrectly, godot.onInitNativeLayer should execute this C++ function.

Great, do you find the source line that caused the exception?

You can search for it with Android Studio. But I don’t yet know why the function returns false.

  • Unable to initialize engine render view
  • Unable to initialize engine native layer

I think we have to find the native code called to initialize “engine render view” and to initialize “engine native layer”. I think the java calls are ONLY the binds to the native cpp code so I think we have to search for the bug in cpp native code and NOT in java one. At least for this bug.

Have you been able to set up Android Studio successfully? :slight_smile:

use Step Into

Bildschirmfoto 2023-12-31 um 00.09.21

On my old “potato” smartphone (bought for 90 € 6 years ago) it is very cumbersome, I have to wait over 3 minutes for the function godot.onInitNativeLayer. :slight_smile:
I have to continue working with Logcat output.

Yes, I’m just using Android Studio, but any time I use F7 for Step Into, it ask to me to use the Arrow Keys to choose the direction…???

On Windows?

And Smart step into Shift+F7 ?