Kotlin code stack trace shows Java line numbers

2019-07-13 22:50发布

问题:

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?

回答1:

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.