从APK文件到项目的逆向工程。

时间:2022-06-06 10:17:05

I accidently erased my project from Eclipse, and all I have left is the APK file which I transferred to my phone. Is there a way to reverse the process of exporting an application to the .apk file, so I can get my project back?

我意外地从Eclipse中删除了我的项目,剩下的就是我转到我手机上的APK文件。是否有一种方法可以将应用程序导出到.apk文件中,从而使我的项目返回?

10 个解决方案

#1


221  

There are two useful tools which will generate Java code (rough but good enough) from an unknown APK file.

有两个有用的工具可以从一个未知的APK文件中生成Java代码(粗糙但足够好)。

  1. Download dex2jar tool from dex2jar.
  2. 从dex2jar下载dex2jar工具。
  3. Use the tool to convert the APK file to JAR:

    使用该工具将APK文件转换为JAR:

    $ d2j-dex2jar.bat demo.apk
    dex2jar demo.apk -> ./demo-dex2jar.jar
    
  4. Once the JAR file is generated, use JD-GUI to open the JAR file. You will see the Java files.

    生成JAR文件后,使用JD-GUI打开JAR文件。您将看到Java文件。

The output will be similar to:

输出将类似于:

从APK文件到项目的逆向工程。

#2


64  

First of all I recommend this video may this is clears all yours doubts

首先,我推荐这段视频可以澄清你的疑惑。

If not please go through it

如果不是,请仔细检查。

Procedure for decoding .apk files, step-by-step method:

解码的过程。apk文件,一步一步法:

Step 1:

步骤1:

Make a new folder and put .apk file in it (which you want to decode). Now rename the extension of this .apk file to .zip (eg.: rename from filename.apk to filename.apk.zip) and save it.

创建一个新的文件夹并将.apk文件放入其中(您想要解码)。现在将这个.apk文件的扩展名重命名为.zip(如。:从文件名重命名。apk到filename.apk.zip)并保存它。

If problems in the converting into .zip please refers link

如果转换成。zip的问题请参考链接。

After getting .zip now you get classes.dex files, etc. At this stage you are able to see drawable but not xml and java files, so continue. If you don’t see the extensions go through check the configuration

在获得.zip之后,您可以获得类。dex文件,等等。在这个阶段,您可以看到drawable而不是xml和java文件,所以继续。如果没有看到扩展,请检查配置。

Step 2:

步骤2:

Now extract this zip apk file in the same folder. Now download dex2jar from this link

现在将zip apk文件解压到同一个文件夹中。现在从这个链接下载dex2jar。

and extract it to the same folder. Now open command prompt and change directory to that folder.

并将其解压到相同的文件夹中。现在打开命令提示符并将目录更改为该文件夹。

Then write dex2jar classes.dex and press enter. Now you get classes.dex.dex2jar file in the same folder.

然后写上dex2jar类。dex和按回车。现在你得到了class。dex.dex2jar文件在同一个文件夹里。

Then download java decompiler

然后下载java编译器的

And now double click on jd-gui and click on open file. Then open classes.dex.dex2jar file from that folder. Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name. Extract that zip file (classes_dex2jar.src.zip) and you will get all java files of the application.

现在双击jd-gui并单击打开文件。然后打开class .dex.dex2jar文件。现在,您获得了类文件并保存了所有这些类文件(单击文件,然后单击“在jd-gui中”使用src名称“保存所有源代码”)。提取该zip文件(classes_dex2jar.src.zip),您将得到应用程序的所有java文件。

At this stage you get java source but the xml files are still unreadable, so continue.

在这个阶段,您将获得java源代码,但是xml文件仍然是不可读的,所以继续。

Step 3:

步骤3:

Now open another new folder and put these files

现在打开另一个新的文件夹并放入这些文件。

  1. put .apk file which you want to decode

    放入。apk文件,你想要解码。

  2. download Apktool for windows v1.x And Apktool

    为windows v1下载Apktool。x和Apktool

install window using google and put in the same folder

使用谷歌安装窗口并放入相同的文件夹。

  1. download framework-res.apk file using google and put in the same folder (Not all apk file need framework-res.apk file)

    下载framework-res。apk文件使用谷歌并放入相同的文件夹(并非所有apk文件都需要框架-res。apk文件)

  2. Open a command window

    打开一个命令窗口

  3. Navigate to the root directory of APKtool and type the following command: apktool if framework-res.apk.

    导航到APKtool的根目录,并键入下面的命令:如果框架-res.apk, APKtool。

Above command should result in Framework installed ....

以上命令会导致框架安装....

  1. apktool d "appName".apk ("appName" denotes application which you want to decode) now you get a file folder in that folder and now you can easily read xml files also.
  2. apktool d“浏览器名称”。apk(“appName”表示你想要解码的应用程序)现在你可以在那个文件夹里找到一个文件夹,现在你也可以轻松地读取xml文件了。

Step 4: Finally we got the res/ as well as java code of project which is our target at starting.

步骤4:最终我们得到了项目的res/和java代码,这是我们开始的目标。

P.S. If you are not able to get res folder by above steps please do install new apktool

如果您无法通过以上步骤获得res文件夹,请安装新的apktool。

  • Is Java 1.7 installed? Install Apktool 2.x
  • Java 1.7安装吗?安装Apktool 2. x
  • Is Java 1.6 or higher installed? Install Apktool 1.x
  • 是否安装了Java 1.6或更高版本?安装Apktool 1. x

Enjoy and happy coding

享受和快乐的编码

#3


38  

No software & No too much steps..

没有软件,也没有太多的步骤。

Just upload your APK & get your all resources from this site..

上传你的APK,从这个网站获取你的所有资源。

https://www.apkdecompilers.com/

https://www.apkdecompilers.com/

This website will decompile the code embedded in APK files and extract all the other assets in the file.

这个网站将把嵌入APK文件的代码分解,并将文件中的所有其他资产提取出来。

note: I decompile my APK file & get code within one miniute from this website

注意:我将APK文件从这个网站的一个miniute中分解。

Update 1:

更新1:

I found another online decompiler site,

我找到了另一个在线反编译网站,

http://www.javadecompilers.com/apk/ - Not working continuously asking for popup blocking

http://www.javadecompilers.com/apk/ -不工作不断地请求弹出式阻塞。

Update 2:

更新2:

I found apk decompiler app in play store,

我在play store找到apk反编译app,

https://play.google.com/store/apps/details?id=com.njlabs.showjava

https://play.google.com/store/apps/details?id=com.njlabs.showjava

We can decompile the apk files in our android phone. and also we can able to view the java & xml files in this application

我们可以将apk文件在android手机中分解。我们还可以在这个应用程序中查看java和xml文件。

Update 3:

更新3:

We can use another option Analyze APK feature from Android studio 2.2 version

我们可以使用另一个选项分析Android studio 2.2版本的APK功能。

Build -> Analyze APK -> Select your APK -> it give results

构建->分析APK ->选择APK ->,结果。

从APK文件到项目的逆向工程。

#4


4  

Not really. There are a number of dex disassembler/decompiler suites out there such as smali, or dex2jar that will generate semi-humanreadable output (in the case of dex2jar, you can get java code through the use of something like JD-GUI but the process is not perfect and it is very unlikely that you'll be able to 100% recreate your source code. However, it could potentially give you a place to start rebuilding your source tree.

不是真的。有许多敏捷反汇编程序/反编译器套件smali等,或将产生semi-humanreadable dex2jar输出(dex2jar的情况下,你可以通过使用java代码类似JD-GUI但是这个过程并不完美,很可能你就可以100%再现您的源代码。但是,它可能会给你一个地方来开始重建你的源树。

#5


4  

There is a new way to do this.

有一种新的方法可以做到这一点。

Android Studio 2.2 has APK Analyzer it will give lot of info about apk, checkout it here :- http://android-developers.blogspot.in/2016/05/android-studio-22-preview-new-ui.html

Android Studio 2.2有APK分析程序,它将提供很多关于APK的信息,在这里签出:- http://android- developers.blogspot.in/2016/05/androidstudio22 - preview-_new -ui.html。

从APK文件到项目的逆向工程。

#6


3  

Yes, you can get your project back. Just rename the yourproject.apk file to yourproject.zip, and you will get all the files inside that ZIP file. We are changing the file extension from .apk to .zip. From that ZIP file, extract the classes.dex file and decompile it by following way.

是的,你可以取回你的项目。重命名志愿者项目。apk文件志愿者项目。zip,你会得到zip文件里面的所有文件。我们正在将文件扩展名从.apk更改为.zip。从该ZIP文件中提取类.dex文件并通过以下方式将其分解。

First, you need a tool to extract all the (compiled) classes on the DEX to a JAR. There's one called dex2jar, which is made by a Chinese student.

首先,您需要一个工具将DEX上的所有(编译的)类提取到一个JAR中。有一个叫dex2jar,是一个中国学生做的。

Then, you can use JD-GUI to decompile the classes in the JAR to source code. The resulting source code should be quite readable, as dex2jar applies some optimizations.

然后,您可以使用JD-GUI将JAR中的类分解到源代码。生成的源代码应该是相当可读的,因为dex2jar应用了一些优化。

#7


2  

Follow below steps to do this or simply use apkToJava gem for this process, it even takes care of installing the required tools for it to work.

遵循以下步骤,或者简单地使用apkToJava gem来完成这个过程,它甚至需要安装所需的工具来工作。

  • convert apk file to zip
  • 将apk文件转换为zip。
  • unzip the file
  • 解压该文件
  • extract classes.dex from it
  • 从中提取classes.dex
  • use dex to jar to convert classes.dex into jar file
  • 用dex将类。dex转换成jar文件。
  • use jadx gui to open the jar file as java source code
  • 使用jadx gui打开jar文件作为java源代码。

#8


1  

For the Android platform, you can try ShowJava, available on the Play Store.

对于Android平台,您可以尝试ShowJava,在Play Store上可用。

You can consult the generated code through the app interface and the generated java files and folders structure are stored in ShowJava folder in /sdcard, alongside the resulting .jar file from the conversion.

您可以通过应用程序接口查询生成的代码,生成的java文件和文件夹结构存储在/sdcard中的ShowJava文件夹中,并与所生成的.jar文件一起存储在转换中。

The app is free with an ad banner at the bottom of the main view, but there is an in-app purchase option (3,99$) to remove it. In-app purchase does not add any functionality beside removing the ad banner.

该应用程序在主视图底部有一个广告横幅,但有一个内购选项(399美元)来移除它。In-app purchase没有添加任何功能,除了删除广告横幅。

Disclosure : I'm not the developer of the app neither I'm affiliated with him in any way.

信息披露:我不是这款应用的开发者,我和他有任何关系。

#9


0  

If you are looking for a professional alternative, have a look at JEB Decompiler from PNF Software.

如果您正在寻找一个专业的替代方案,请查看一下来自PNF软件的JEB反编译器。

There is a demo version that will let you decompile most code.

这里有一个演示版本,它可以让你将大部分代码分解。

#10


0  

Below are some of the tools which you can use to perform reverse engineering from an APK file to source code :

下面是一些工具,您可以使用这些工具从APK文件到源代码执行反向工程:

  1. Dex2jar
  2. Dex2jar
  3. Java decompiler
  4. Java编译器的
  5. Apktool
  6. Apktool
  7. Apk Analyser
  8. Apk分析器

#1


221  

There are two useful tools which will generate Java code (rough but good enough) from an unknown APK file.

有两个有用的工具可以从一个未知的APK文件中生成Java代码(粗糙但足够好)。

  1. Download dex2jar tool from dex2jar.
  2. 从dex2jar下载dex2jar工具。
  3. Use the tool to convert the APK file to JAR:

    使用该工具将APK文件转换为JAR:

    $ d2j-dex2jar.bat demo.apk
    dex2jar demo.apk -> ./demo-dex2jar.jar
    
  4. Once the JAR file is generated, use JD-GUI to open the JAR file. You will see the Java files.

    生成JAR文件后,使用JD-GUI打开JAR文件。您将看到Java文件。

The output will be similar to:

输出将类似于:

从APK文件到项目的逆向工程。

#2


64  

First of all I recommend this video may this is clears all yours doubts

首先,我推荐这段视频可以澄清你的疑惑。

If not please go through it

如果不是,请仔细检查。

Procedure for decoding .apk files, step-by-step method:

解码的过程。apk文件,一步一步法:

Step 1:

步骤1:

Make a new folder and put .apk file in it (which you want to decode). Now rename the extension of this .apk file to .zip (eg.: rename from filename.apk to filename.apk.zip) and save it.

创建一个新的文件夹并将.apk文件放入其中(您想要解码)。现在将这个.apk文件的扩展名重命名为.zip(如。:从文件名重命名。apk到filename.apk.zip)并保存它。

If problems in the converting into .zip please refers link

如果转换成。zip的问题请参考链接。

After getting .zip now you get classes.dex files, etc. At this stage you are able to see drawable but not xml and java files, so continue. If you don’t see the extensions go through check the configuration

在获得.zip之后,您可以获得类。dex文件,等等。在这个阶段,您可以看到drawable而不是xml和java文件,所以继续。如果没有看到扩展,请检查配置。

Step 2:

步骤2:

Now extract this zip apk file in the same folder. Now download dex2jar from this link

现在将zip apk文件解压到同一个文件夹中。现在从这个链接下载dex2jar。

and extract it to the same folder. Now open command prompt and change directory to that folder.

并将其解压到相同的文件夹中。现在打开命令提示符并将目录更改为该文件夹。

Then write dex2jar classes.dex and press enter. Now you get classes.dex.dex2jar file in the same folder.

然后写上dex2jar类。dex和按回车。现在你得到了class。dex.dex2jar文件在同一个文件夹里。

Then download java decompiler

然后下载java编译器的

And now double click on jd-gui and click on open file. Then open classes.dex.dex2jar file from that folder. Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name. Extract that zip file (classes_dex2jar.src.zip) and you will get all java files of the application.

现在双击jd-gui并单击打开文件。然后打开class .dex.dex2jar文件。现在,您获得了类文件并保存了所有这些类文件(单击文件,然后单击“在jd-gui中”使用src名称“保存所有源代码”)。提取该zip文件(classes_dex2jar.src.zip),您将得到应用程序的所有java文件。

At this stage you get java source but the xml files are still unreadable, so continue.

在这个阶段,您将获得java源代码,但是xml文件仍然是不可读的,所以继续。

Step 3:

步骤3:

Now open another new folder and put these files

现在打开另一个新的文件夹并放入这些文件。

  1. put .apk file which you want to decode

    放入。apk文件,你想要解码。

  2. download Apktool for windows v1.x And Apktool

    为windows v1下载Apktool。x和Apktool

install window using google and put in the same folder

使用谷歌安装窗口并放入相同的文件夹。

  1. download framework-res.apk file using google and put in the same folder (Not all apk file need framework-res.apk file)

    下载framework-res。apk文件使用谷歌并放入相同的文件夹(并非所有apk文件都需要框架-res。apk文件)

  2. Open a command window

    打开一个命令窗口

  3. Navigate to the root directory of APKtool and type the following command: apktool if framework-res.apk.

    导航到APKtool的根目录,并键入下面的命令:如果框架-res.apk, APKtool。

Above command should result in Framework installed ....

以上命令会导致框架安装....

  1. apktool d "appName".apk ("appName" denotes application which you want to decode) now you get a file folder in that folder and now you can easily read xml files also.
  2. apktool d“浏览器名称”。apk(“appName”表示你想要解码的应用程序)现在你可以在那个文件夹里找到一个文件夹,现在你也可以轻松地读取xml文件了。

Step 4: Finally we got the res/ as well as java code of project which is our target at starting.

步骤4:最终我们得到了项目的res/和java代码,这是我们开始的目标。

P.S. If you are not able to get res folder by above steps please do install new apktool

如果您无法通过以上步骤获得res文件夹,请安装新的apktool。

  • Is Java 1.7 installed? Install Apktool 2.x
  • Java 1.7安装吗?安装Apktool 2. x
  • Is Java 1.6 or higher installed? Install Apktool 1.x
  • 是否安装了Java 1.6或更高版本?安装Apktool 1. x

Enjoy and happy coding

享受和快乐的编码

#3


38  

No software & No too much steps..

没有软件,也没有太多的步骤。

Just upload your APK & get your all resources from this site..

上传你的APK,从这个网站获取你的所有资源。

https://www.apkdecompilers.com/

https://www.apkdecompilers.com/

This website will decompile the code embedded in APK files and extract all the other assets in the file.

这个网站将把嵌入APK文件的代码分解,并将文件中的所有其他资产提取出来。

note: I decompile my APK file & get code within one miniute from this website

注意:我将APK文件从这个网站的一个miniute中分解。

Update 1:

更新1:

I found another online decompiler site,

我找到了另一个在线反编译网站,

http://www.javadecompilers.com/apk/ - Not working continuously asking for popup blocking

http://www.javadecompilers.com/apk/ -不工作不断地请求弹出式阻塞。

Update 2:

更新2:

I found apk decompiler app in play store,

我在play store找到apk反编译app,

https://play.google.com/store/apps/details?id=com.njlabs.showjava

https://play.google.com/store/apps/details?id=com.njlabs.showjava

We can decompile the apk files in our android phone. and also we can able to view the java & xml files in this application

我们可以将apk文件在android手机中分解。我们还可以在这个应用程序中查看java和xml文件。

Update 3:

更新3:

We can use another option Analyze APK feature from Android studio 2.2 version

我们可以使用另一个选项分析Android studio 2.2版本的APK功能。

Build -> Analyze APK -> Select your APK -> it give results

构建->分析APK ->选择APK ->,结果。

从APK文件到项目的逆向工程。

#4


4  

Not really. There are a number of dex disassembler/decompiler suites out there such as smali, or dex2jar that will generate semi-humanreadable output (in the case of dex2jar, you can get java code through the use of something like JD-GUI but the process is not perfect and it is very unlikely that you'll be able to 100% recreate your source code. However, it could potentially give you a place to start rebuilding your source tree.

不是真的。有许多敏捷反汇编程序/反编译器套件smali等,或将产生semi-humanreadable dex2jar输出(dex2jar的情况下,你可以通过使用java代码类似JD-GUI但是这个过程并不完美,很可能你就可以100%再现您的源代码。但是,它可能会给你一个地方来开始重建你的源树。

#5


4  

There is a new way to do this.

有一种新的方法可以做到这一点。

Android Studio 2.2 has APK Analyzer it will give lot of info about apk, checkout it here :- http://android-developers.blogspot.in/2016/05/android-studio-22-preview-new-ui.html

Android Studio 2.2有APK分析程序,它将提供很多关于APK的信息,在这里签出:- http://android- developers.blogspot.in/2016/05/androidstudio22 - preview-_new -ui.html。

从APK文件到项目的逆向工程。

#6


3  

Yes, you can get your project back. Just rename the yourproject.apk file to yourproject.zip, and you will get all the files inside that ZIP file. We are changing the file extension from .apk to .zip. From that ZIP file, extract the classes.dex file and decompile it by following way.

是的,你可以取回你的项目。重命名志愿者项目。apk文件志愿者项目。zip,你会得到zip文件里面的所有文件。我们正在将文件扩展名从.apk更改为.zip。从该ZIP文件中提取类.dex文件并通过以下方式将其分解。

First, you need a tool to extract all the (compiled) classes on the DEX to a JAR. There's one called dex2jar, which is made by a Chinese student.

首先,您需要一个工具将DEX上的所有(编译的)类提取到一个JAR中。有一个叫dex2jar,是一个中国学生做的。

Then, you can use JD-GUI to decompile the classes in the JAR to source code. The resulting source code should be quite readable, as dex2jar applies some optimizations.

然后,您可以使用JD-GUI将JAR中的类分解到源代码。生成的源代码应该是相当可读的,因为dex2jar应用了一些优化。

#7


2  

Follow below steps to do this or simply use apkToJava gem for this process, it even takes care of installing the required tools for it to work.

遵循以下步骤,或者简单地使用apkToJava gem来完成这个过程,它甚至需要安装所需的工具来工作。

  • convert apk file to zip
  • 将apk文件转换为zip。
  • unzip the file
  • 解压该文件
  • extract classes.dex from it
  • 从中提取classes.dex
  • use dex to jar to convert classes.dex into jar file
  • 用dex将类。dex转换成jar文件。
  • use jadx gui to open the jar file as java source code
  • 使用jadx gui打开jar文件作为java源代码。

#8


1  

For the Android platform, you can try ShowJava, available on the Play Store.

对于Android平台,您可以尝试ShowJava,在Play Store上可用。

You can consult the generated code through the app interface and the generated java files and folders structure are stored in ShowJava folder in /sdcard, alongside the resulting .jar file from the conversion.

您可以通过应用程序接口查询生成的代码,生成的java文件和文件夹结构存储在/sdcard中的ShowJava文件夹中,并与所生成的.jar文件一起存储在转换中。

The app is free with an ad banner at the bottom of the main view, but there is an in-app purchase option (3,99$) to remove it. In-app purchase does not add any functionality beside removing the ad banner.

该应用程序在主视图底部有一个广告横幅,但有一个内购选项(399美元)来移除它。In-app purchase没有添加任何功能,除了删除广告横幅。

Disclosure : I'm not the developer of the app neither I'm affiliated with him in any way.

信息披露:我不是这款应用的开发者,我和他有任何关系。

#9


0  

If you are looking for a professional alternative, have a look at JEB Decompiler from PNF Software.

如果您正在寻找一个专业的替代方案,请查看一下来自PNF软件的JEB反编译器。

There is a demo version that will let you decompile most code.

这里有一个演示版本,它可以让你将大部分代码分解。

#10


0  

Below are some of the tools which you can use to perform reverse engineering from an APK file to source code :

下面是一些工具,您可以使用这些工具从APK文件到源代码执行反向工程:

  1. Dex2jar
  2. Dex2jar
  3. Java decompiler
  4. Java编译器的
  5. Apktool
  6. Apktool
  7. Apk Analyser
  8. Apk分析器