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

前端 未结 27 1789
难免孤独
难免孤独 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: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!

提交回复
热议问题