Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin code stack trace shows Java line numbers

I'm trying to debug a couple of crashes for my app in the Google Play Store, but the stack traces showing in the Play Store show Java filenames and line numbers instead of direct references to my Kotlin code. I viewed the Java code in Android Studio, but the line numbers do not match.

To view the Java code, I converted to byte code and then decompiled to Java. There's also a more direct option in Android Studio to 'Decompile Kotlin to Java', but this is disabled; my hope was that this would give me a better match against the stack traces.

How can I use the stack trace info I see in crash reports in the Play Store to identify the problems in my Kotlin source code?

like image 251
Crag Avatar asked Oct 24 '18 13:10

Crag


People also ask

How do I read a Java stack trace?

To read this stack trace, start at the top with the Exception's type - ArithmeticException and message The denominator must not be zero . This gives an idea of what went wrong, but to discover what code caused the Exception, skip down the stack trace looking for something in the package com.

How do I read stack trace errors?

The stack trace first prints the function call that caused the error and then prints the previous underlying calls that led up to the faulty call. Therefore, reading the first line of the stack trace shows you the exact function call that threw an error.

What are stack trace errors?

Stack trace error is a generic term frequently associated with long error messages. The stack trace information identifies where in the program the error occurs and is helpful to programmers. For users, the long stack track information may not be very useful for troubleshooting web errors.


2 Answers

Copy your stack trace, open Android Studio or IntelliJ IDEA, click Analyze -> Analyze Stack Trace, paste it and click Ok. Class names with lines will become clickable and clicks should work correctly.

like image 87
Miha_x64 Avatar answered Nov 18 '22 02:11

Miha_x64


Answer update, in Android Studio 4.1, it looks like the menu option changed:

Analyze -> Stack Trace or Thread Dump...
like image 3
Crag Avatar answered Nov 18 '22 03:11

Crag