How to get stack trace file on Android?

I am developing a game on an android device, and i have android studio Logcat window open on my laptop to show me the stack trace and exceptions.
The problem is that my game is heavily dependant on the phone sensors, so sometimes i want to test the game by walking around and moving the phone. Whenever i do that i don’t have Logcat available, so i did some writing to a log.txt file from within the code so after i am done playing i can look at the text file.
Unfortunately this is not scalable as i need to create hundrads of extra line of codes just to write to log.txt
I have googled a lot but this is the first time i have not found a solution.
I have also looked at the auto-generated IL2CPP folder in my app file on the phone but there was nothing there that helped.

You can connect to your phone via wifi, either by using adb connect (Android Debug Bridge (adb)  |  Android Studio  |  Android Developers) or via logcat package Device Connection | Android Logcat | 1.2.3.

That way you won’t need to have phone connected via cable, and you’ll be able to see the logcat all the time

1 Like

This may help How To - Capturing Device Logs on Android