简体   繁体   English

如何正确重新编译apk文件?

[英]How to correctly re-compile an apk file?

i was trying to inspect an.apk file for a project, so i decided to decompile it using APKtool using:我试图检查一个项目的 .apk 文件,所以我决定使用 APKtool 对其进行反编译:

apktool d name.apk

I find what i wanted, changed it (i modified just a bunch of.json file and some.png, all in the /assets folder), but after re-building it with我找到了我想要的,改变了它(我只修改了一堆.json 文件和一些.png,都在 /assets 文件夹中),但是在重新构建它之后

apktool b name -o new.apk

I had some problems in installing the app on my device.我在我的设备上安装应用程序时遇到了一些问题。 Any suggestions?有什么建议么?

It could be the signature of the.apk, according to other similar questions.根据其他类似的问题,它可能是 the.apk 的签名。 But none of those explain the method to sign the.apk file in a correct way.但是这些都没有解释以正确方式签署.apk文件的方法。

The following is for your reference以下内容供您参考


Compile, decompile and sign APK using apktool utility.使用 apktool 实用程序编译、反编译和签名 APK。

  1. Download latest apktool version.下载最新的 apktool 版本。

  2. Download the batch file and aapt.exe.下载批处理文件和 aapt.exe。

  3. Create a folder anywhere in the PC and put all the apktool.jar, aapt.exe and the batch script in that folder.在 PC 的任意位置创建一个文件夹,并将所有 apktool.jar、aapt.exe 和批处理脚本放在该文件夹中。

  4. Open command prompt.打开命令提示符。

  5. Navigate to the folder where you placed apktool.jar, batch script and the aapt.exe.导航到放置 apktool.jar、批处理脚本和 aapt.exe 的文件夹。

  6. Now, you need to install the file using the " IF " command.现在,您需要使用“IF”命令安装文件。

  7. Type the following command.键入以下命令。

    apktool if name-of-the-app.apk

  8. For decompiling use the command "d".反编译使用命令“d”。 The "d" stands for decompile. “d”代表反编译。

    apktool d name-of-the-app.apk

  9. After the app is correctly decompiled, a new folder will be created in the same folder where you placed your app.正确反编译应用程序后,将在您放置应用程序的同一文件夹中创建一个新文件夹。 This contains all the xml's and smali files which can be edited for different mode's.这包含所有可以为不同模式编辑的 xml 和 smali 文件。

  10. To recompile the app use the following command " B ".要重新编译应用程序,请使用以下命令“B”。 The "b" simply means recompile. “b”只是意味着重新编译。

    apktool b name-of-the-app-folder

  11. The final modded app will be in the "dist" folder located inside the original app folder created by apktool.最终修改后的应用程序将位于 apktool 创建的原始应用程序文件夹内的“dist”文件夹中。

Signing the apk签署apk

  1. open a new command prompt and change into the sign-apk directory using cmd打开一个新的命令提示符并使用 cmd 更改为 sign-apk 目录

  2. move the modified-unsigned apk into this folder将修改后未签名的 apk 移动到此文件夹中

  3. then type the following command -然后键入以下命令 -

    java -jar signapk.jar certificate.pem key.pk8 path-of-the-folder-contaning-the-apk.apk path-of-the-new-signed-apk.apk

  4. Once compiled, the signed apk will be found in the same folder.编译后,签名的 apk 将在同一文件夹中找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM