如何注入code到现有的.apk? [英] How to inject code into an existing Apk?

查看:274
本文介绍了如何注入code到现有的.apk?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是可能的反编译和重新编译APK。而我看​​到这个帖子:注入code到APK 之前,但我想是不是反编译或逆向工程

I know this is possible to decompile and recompile an apk. And I saw this post : Injecting code into APK before, But what I want is not decompiling or reverse engineering.

在我来说,我只想做一些游戏,它使用与手柄兼容触摸事件。我见过一些公司做这样的事情,并让Android游戏与游戏手柄兼容。 不幸的是我没有找到解决方案,以C $ CS约$注入现有的APK。

In my case I just want to make some games that uses touch events compatible with gamepad. I've seen some companies that do something like this and make android games compatible with their gamepads. Unfortunately I found no solution to inject some codes into an existing apk.

所以,我的问题是:

有没有办法做一些改变成一个APK(改变触摸和按键事件在游戏应用程序),并添加了一些codeS到,如果没有影响的真正来源$ C ​​$ C?

Is there a way to do some changes into an apk (changing touch and key events in game application) and add some codes into that without effecting the real source code ?

推荐答案

为此,首先你这个反编译APK到源$ C ​​$ C 对于反编译的APK以下目的是用来

For this purpose first of all you decompile this apk into source code for decompiling the apk following purpose is used

步骤1:

创建一个新的文件夹,并复制了要脱code中的的.apk文件。

Make a new folder and copy over the .apk file that you want to decode.

现在重新命名这个的.apk文件的扩展名更改为.zip(例如从filename.apk重命名为filename.zip)并将其保存。现在,您可以访问classes.dex文件,等等。在这个阶段,你都能够看到可绘制而不是XML和Java文件,如此继续下去。

Now rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. Now you can access the classes.dex files, etc. At this stage you are able to see drawables but not xml and java files, so continue.

步骤2:

现在提取在同一文件夹此.zip文件(或新建文件夹)。

Now extract this .zip file in the same folder (or NEW FOLDER).

下载dex2jar(的https://$c$c.google.com/p/dex2jar/downloads/detail?name=dex2jar-0.0.9.15.zip&can=2&q=)并将其解压到同一文件夹(或新建文件夹)。

Download dex2jar (https://code.google.com/p/dex2jar/downloads/detail?name=dex2jar-0.0.9.15.zip&can=2&q=) and extract it to the same folder (or NEW FOLDER).

将classes.dex文件到dex2jar文件夹。

Move the classes.dex file into the dex2jar folder.

现在打开命令提示符,将目录更改到该文件夹​​中(或新建文件夹)。然后写d2j-dex2jar classes.dex和preSS进入。现在,您可以在同一个文件夹中的classes_dex2jar.jar文件。

Now open command prompt and change directory to that folder (or NEW FOLDER). Then write d2j-dex2jar classes.dex and press enter. You now have the classes_dex2jar.jar file in the same folder.

下载Java反编译器( http://jd.benow.ca/ ),双击jd-图形用户界面,点击打开文件,并打开classes.dex.dex2jar文件从该文件夹:现在你得到的类文件

Download java decompiler(http://jd.benow.ca/), double click on jd-gui, click on open file, and open classes.dex.dex2jar file from that folder: now you get class files.

保存所有的这些类文件(在JD-GUI中,单击文件 - >保存所有源)由SRC名。在这个阶段,你得到的Java源代码,但.xml文件仍然无法读取,如此继续下去。

Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage you get the java source but the .xml files are still unreadable, so continue.

步骤3:

现在打开另一个新文件夹

Now open another new folder

放入要脱code中的.apk文件的文件

Put in the .apk file which you want to decode

下载apktool的最新版本(<一href="https://$c$c.google.com/p/android-apktool/downloads/detail?name=apktool1.5.2.tar.bz2&can=2&q=" rel="nofollow">https://$c$c.google.com/p/android-apktool/downloads/detail?name=apktool1.5.2.tar.bz2&can=2&q=)与apktool安装窗口(<一href="https://$c$c.google.com/p/android-apktool/downloads/detail?name=apktool-install-windows-r05-ibot.tar.bz2&can=2&q=" rel="nofollow">https://$c$c.google.com/p/android-apktool/downloads/detail?name=apktool-install-windows-r05-ibot.tar.bz2&can=2&q= )(既可以从相同的链接下载),并将其放置在同一文件夹

Download the latest version of apktool (https://code.google.com/p/android-apktool/downloads/detail?name=apktool1.5.2.tar.bz2&can=2&q=) AND apktool install window (https://code.google.com/p/android-apktool/downloads/detail?name=apktool-install-windows-r05-ibot.tar.bz2&can=2&q= ) (both can be downloaded from the same link) and place them in the same folder

下载框架res.apk,并把它放在同一个文件夹中(不是所有的apk文件需要这个文件,但它不会伤害)

Download framework-res.apk and put it in the same folder (Not all apk file need this file, but it doesn't hurt)

打开命令窗口

导航到APKtool的根目录,然后键入以下命令:如果apktool框架res.apk

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

apktoolðmyApp.apk(其中myApp.apk表示要取消code中的文件名)

apktool d myApp.apk (where myApp.apk denotes the filename that you want to decode)

现在你会得到一个文件夹的文件夹中,可以轻松读取apk文件的XML文件。

now you get a file folder in that folder and can easily read the apk's xml files.

步骤4:

这不是任何一个步骤只是复制这两个文件夹的内容(在这种情况下,两个新的文件夹),以单一个

It's not any step just copy contents of both folder(in this case both new folder)to the single one

和更新源$ C ​​$ C ...

and update the source code...

这篇关于如何注入code到现有的.apk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆