我笔记本电脑上的硬盘刚刚崩溃,我丢失了过去两个月一直在开发的应用程序的所有源代码。我只有一个APK文件,它存储在我发给朋友的电子邮件中。
有没有办法从这个APK文件中提取我的源代码?
我笔记本电脑上的硬盘刚刚崩溃,我丢失了过去两个月一直在开发的应用程序的所有源代码。我只有一个APK文件,它存储在我发给朋友的电子邮件中。
有没有办法从这个APK文件中提取我的源代码?
当前回答
几天来,我一直想让dex2jar在一台软呢帽31笔记本电脑上与一台无法工作的apk进行比较,这让我发疯了。这个python3脚本在几分钟内就完成了这个任务,安装jdgui使类文件变得可读。
http://java-decompiler.github.io/
https://github.com/Storyyeller/enjarify
具体来说,下面是我运行的:
# 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
现在应该可以使用以下方法获取类文件:
$> enjarify yourapkfile.apk
要启动jd-gui:
$> jd-gui
那就打开你的课堂文件吧!
其他回答
apktool是你能尝试的最好的方法。我用它保存了一些xml,但老实说,我不知道它如何与.java代码一起工作。
我建议您拥有一个代码库,即使您是唯一的程序员。我一直在为自己的项目使用Project Locker。它为您提供免费svn和git repo。
这两篇文章描述了如何结合使用apktool和dex2jar来获取APK文件并创建一个可以构建和运行它的Eclipse项目。
http://blog.inyourbits.com/2012/11/extending-existing-android-applications.htmlhttp://blog.inyourbits.com/2012/12/extending-existing-android-applications.html
基本上你:
使用apktool从apk中获取资源文件使用dex2jar获取一个jar文件,其中包含Eclipse喜欢的格式的类。创建一个Eclipse项目,指向资源文件和新的jar文件使用zip实用程序打开jar文件并删除现有资源使用JDGui打开jar文件以查看源代码从JDGui中获取所需的任何源代码,将其粘贴到Eclipse中的一个类中并进行修改从jar文件中删除该类(这样就不会多次定义相同的类)运行它。
几天来,我一直想让dex2jar在一台软呢帽31笔记本电脑上与一台无法工作的apk进行比较,这让我发疯了。这个python3脚本在几分钟内就完成了这个任务,安装jdgui使类文件变得可读。
http://java-decompiler.github.io/
https://github.com/Storyyeller/enjarify
具体来说,下面是我运行的:
# 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
现在应该可以使用以下方法获取类文件:
$> enjarify yourapkfile.apk
要启动jd-gui:
$> jd-gui
那就打开你的课堂文件吧!
用于反向工程第三方、封闭的二进制Android应用程序的Apktool。
它可以将资源解码为几乎原始的形式,并在进行一些修改后重建它们。
它使逐步调试smali代码成为可能。此外,它还使使用应用程序变得更容易,因为它具有类似项目的文件结构和一些重复任务的自动化,如构建apk等。
http://ibotpeaches.github.io/Apktool/
你可以试试DexPatcher。它甚至与Android Studio集成。它在内部使用Apktool和Dex2Jar。您也可以独立使用这些工具。Apktool反编译apk,并提取.dex文件,可以使用Dex2Jar将其进一步转换为jar。Jar可以使用JD-GUI反编译。在该工具的帮助下,您可以看到Java代码。尽管不能保证反编译代码与实际代码的相似性。市场上有一些高级的代码混淆工具,它们会将代码弄乱,从而使反编译/理解变得困难。例如Proguard