However, if I manually do "Show Kotlin Bytecode" and click on "Decompile" it will show the correct java code.
Go to Tools -> Kotlin -> Show Kotlin Bytecode press Decompile in the header.
Android Studio provides full support for Kotlin, enabling you to add Kotlin files to your existing project and convert Java language code to Kotlin. You can then use all of Android Studio's existing tools with your Kotlin code, including autocomplete, lint checking, refactoring, debugging, and more.
A helper plugin to support decompiler Kotlin bytecode to Java. It is based on CFR Decompiler which doesn't have problems to decompile the bytecode with Kotlin Coroutines. It can be also used for checking the result of Jetpack Compose.
If you write some kotlin and want to see how it gets compiled into JAVA by using the Decompile Kotlin to Java menu, you need to be viewing the compiled .class file and not the Kotlin source .kt file.
After building the app, try to find the compiled *.kt file in the App/build/tmp/kotlin-classes directory. Here is a simple command line you can run in the root of your project to output the location if your Kotlin file is named Hello.kt:
find ./ | grep "Hello.class"
Open the .class file in IntelliJ or Android Studio and the menu will be available to see how your Kotlin was converted to JAVA
Another option for viewing Kotlin decompiled code is to open Kotlin bytecode tab and press Decompile there.
Go to Tools -> Kotlin -> Show Kotlin Bytecode
press Decompile
in the header.
Works for IntelliJ IDEA 2019.3, so I believe it would work in Android Studio as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With