Is there a way to get the source code from an APK file?

前端 未结 27 1833
难免孤独
难免孤独 2020-11-21 06:56

The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months. All I have is the APK file that is st

相关标签:
27条回答
  • 2020-11-21 07:37

    Use this tool http://www.javadecompilers.com/

    But recently, a new wave of decompilers has forayed onto the market: Procyon, CFR, JD, Fernflower, Krakatau, Candle.

    Here's a list of decompilers presented on this site:

    CFR - Free, no source-code available, http://www.benf.org/other/cfr/ Author: Lee Benfield

    Very well-updated decompiler! CFR is able to decompile modern Java features - Java 9 modules, Java 8 lambdas, Java 7 String switches etc. It'll even make a decent go of turning class files from other JVM langauges back into java!

    JD - free for non-commercial use only, http://jd.benow.ca/ Author: Emmanuel Dupuy

    Updated in 2015. Has its own visual interface and plugins to Eclipse and IntelliJ . Written in C++, so very fast. Supports Java 5.

    Procyon - open-source, https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler Author: Mike Strobel

    Fernflower - open-source, https://github.com/fesh0r/fernflower Author: Egor Ushakov

    Updated in 2015. Very promising analytical Java decompiler, now becomes an integral part of IntelliJ 14. (https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler) Supports Java up to version 6 (Annotations, generics, enums)

    JAD - given here only for historical reason. Free, no source-code available, jad download mirror Author: Pavel Kouznetsov

    0 讨论(0)
  • 2020-11-21 07:38

    I've been driving myself crazy for days trying to get dex2jar to work on a fedora 31 laptop against an apk that just wasn't going to work. This python 3 script did the trick in minutes and installing jd-gui made class files human readable.

    http://java-decompiler.github.io/

    https://github.com/Storyyeller/enjarify

    specifically, here's what I ran:

    # i installed apktool before the rest of the stuff, may not need it but here it is
    $> cd /opt
    $> sudo mkdir apktool
    $> cd apktool/
    $> sudo wget https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool
    $> sudo wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.1.jar
    $> sudo mv apktool_2.4.1.jar apktool.jar
    $> sudo mv apktool* /usr/bin/
    $> sudo chmod a+x /usr/bin/apktool*
    
    # and enjarify
    $> cd /opt
    $> sudo git clone https://github.com/Storyyeller/enjarify.git
    $> cd enjarify/
    $> sudo ln -s /opt/enjarify/enjarify.sh /usr/bin/enjarify
    
    # and finally jd-gui
    $> cd /opt
    $> sudo git clone https://github.com/java-decompiler/jd-gui.git
    $> cd jd-gui/
    $> sudo ./gradlew build
    
    # I made an alias to kick of the jd-gui with short commandline rather than long java -jar blahblahblah :)
    $> echo "jd-gui='java -jar /opt/jd-gui/build/launch4j/lib/jd-gui-1.6.6.jar'" >> ~/.bashrc
    

    Now one should be able to rum the following to get class files:

    $> enjarify yourapkfile.apk
    

    And to start jd-gui:

    $> jd-gui
    

    Then just open your class files!

    0 讨论(0)
  • 2020-11-21 07:39

    May be the easy one to see the source:

    In Android studio 2.3, Build -> Analyze APK -> Select the apk that you want to decompile.
    You will see it's source code.

    Link for reference:
    https://medium.com/google-developers/making-the-most-of-the-apk-analyzer-c066cb871ea2

    0 讨论(0)
  • 2020-11-21 07:40

    Below ONLINE tool:

    http://www.javadecompilers.com/apk

    it do ALL by one click: decompiled .java files + resources + xml (in one .zip file) with very good decompiler (jadx return java code in places/functions where other compiles return comments inside function like "unable to decompile" or some android assembler/machine code)

    0 讨论(0)
  • 2020-11-21 07:41

    There is also a new application on the Play Store with which it is possible to decompile an apk (system applications too) and view the source code right on your smartphone. It saves the files to your SD card so you can view it on your computer too. It does not require root or something else.

    Just install and have fun. I think this is the easiest way to decompile an app.

    0 讨论(0)
  • 2020-11-21 07:42

    apktool is the best thing you can try. I have saved some xml with it, but honestly I don't know how it will work with the .java code.

    I would recommend you to have a code repository even if your are the only coder. I've been using Project Locker for my own projects. It gives you free svn and git repos.

    0 讨论(0)
提交回复
热议问题