我笔记本电脑上的硬盘刚刚崩溃,我丢失了过去两个月一直在开发的应用程序的所有源代码。我只有一个APK文件,它存储在我发给朋友的电子邮件中。

有没有办法从这个APK文件中提取我的源代码?


当前回答

我发现以下是最简单的方法:

将app.apk重命名为app.zip(将扩展名从apk更改为zip)将zip文件解压缩到文件夹中使用JADX工具读取classes.dex文件中的源代码。

其他回答

apktool是最好的选择。在线apktool服务也存在:http://www.javadecompilers.com/apktool

显然,由于服务的“在线性质”,存在一些限制:您可以提取和研究资产和清单文件,但目前不可能重新编译应用程序。

尽管如此,这是一种“打开”android应用程序的简单方法。

apktool是你能尝试的最好的方法。我用它保存了一些xml,但老实说,我不知道它如何与.java代码一起工作。

我建议您拥有一个代码库,即使您是唯一的程序员。我一直在为自己的项目使用Project Locker。它为您提供免费svn和git repo。

几天来,我一直想让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应用程序的APK文件可以使用以下任何方法反编译:

APKTool(需要在电脑上安装Java)APKTool M(Android应用程序)JavaDecompilers(在线工具包括APKTool实用程序)

资料来源:https://droidmaze.com/how-to-extract-code-from-apk/

有一个应用程序可以实现这一点,通常只需点击几下即可完成。https://github.com/Nuvolect/DeepDive-Android

选择应用程序,在“已安装的应用程序”下选择您的应用程序。如果不是在那里你可以加载APK。选择“提取APK”选择“解压缩APK”选择“使用Jadx分解”。这可能需要几秒钟或几分钟,具体取决于取决于设备的速度

之后,您可以浏览源代码,使用elFinder将其下载到另一台计算机,或使用Lucene进行搜索。

除了Jadx,它还有CFR和Fernflower反编译器。