decompile Kotlin source code from .apk file
Asked Answered
G

1

7

Few days back my Hard Drive courrupted due to this I lost my whole project files. I have an .apk file of that project.

but problem is that the .apk files contain 100% Kotlin language. I found one way to decompile code, but bad luck it doesn't decompile back to Kotlin code. After decompiling I got some weird type written .java classes.

Please help me how can I decompile my .apk file, it was a very important project for me. Is any way please suggest :)

Gellman answered 9/10, 2020 at 16:46 Comment(6)
There are dex to Java decompilers, but I haven't heard of any for Kotlin. But you could use Android Studio to convert the Java to Kotlin. The decompiled code will never look as pretty as the original source. There's no way for the decompiler to know what your code looked like before it was optimized by the bytecode compiler. Also, don't develop anything without version control and backups. BitBucket and GitHub both allow you to back up private projects for free.Amado
Absolutely, it's a pity about what happened, but if you don't have a backup or you didn't push to a remote version control, there's not much you can do to restore the entire project to its original state. You can certainly decompile the .class files back into Java (never seen a KT decompiler yet), but you won't get formatting, comments, project structure, etc. back. :/ May this be a reminder to all users that there are plenty of free git (and others) hosting places on the Internet; not onlly github or gitlab or bitbucket (assuming you're not in a blocked country) :/Berte
thanks for reply...actually i got my project back...what i did, i just decompile my apk and from that i didn't get my project wriiten in kotlin it was written in java...i just make a new project with same package name and i started coping my .kt file and Luckily my java code automatically converted in kotlin by SMART IDE - ANDROID STUDIO :) but still i did some changes in that files becz it contains many redundant files ..that was automatically generatedGellman
@Gellman Hi could you please elaborate how you solved it? I see lots of errors when decompiling from .class to .java and cannot proceed...Sharika
@Sharika as I mentioned in above comment you just do the same. Decompile you apk and you will get .java class then just make a new project and copy codes and paste in new .kt class and IDE will automatically convert your .java to .kt but there will be some error you have to analyze and solve it. If this project i done by yourself only then you can solve that error easily. I know you have to do some efforts, because there is no any other way to decompile apk to source code. In my case it took one week to get my project back.Gellman
@Gellman Thanks! When I get .java class it is very ugly and contains tons of strange symbols and variables, and even get compile errors...Sharika
K
1

To decompile Kotlin code from an APK file, you may use a few tools that are available.

FernFlower: Kotlin code may be decompiled using FernFlower, a Java decompiler. The APK file may be decompiled using FernFlower to produce Java code, which can then be converted back to Kotlin code using a tool like IntelliJ IDEA.

there some more online websites you search on google and also use apk easy tool in windows to decompile source code.

Kussell answered 24/3, 2023 at 3:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.