当前位置:网站首页>Apktool tool usage document
Apktool tool usage document
2022-06-26 05:09:00 【Light ink CGZ】
apktool Tools using documentation
Installation instructions
apktool yes java Language development , What is provided is a jar package , Need to be in java The operating environment is 1.8 above
Input... At the terminal java -version Viewing this computer java edition
Mac OS X:
- download Mac Packaging scripts ( Right click , Save Link as apktool ), Note that the file does not have a suffix
- download apktool-2( Find the latest... Here )
- Will download jar Rename it to apktool.jar
- Combine two files ( apktool.jar&apktool ) Move to /usr/local/bin( need root )
- Make sure both files are executable (chmod +x)
- Try to pass through CLI ( Command line ) function apktool
Introduce
First let's learn apk file , It is a system that contains resources and java Assembly code zip file . Since it is zip file , So we unzip apk What will the file see . Try it and you'll see
classes.dex And other resource files
$ unzip testapp.apk
Archive: testapp.apk
inflating: AndroidManifest.xml
inflating: classes.dex
extracting: res/drawable-hdpi/ic_launcher.png
inflating: res/xml/literals.xml
inflating: res/xml/references.xml
extracting: resources.arsc
You can try to see AndroidManifest.xml file , The display is a pile of , Encrypted gibberish .
P4F0\fnversionCodeversionNameandroid*http://schemas.android.com/apk/res/androidpackageplatformBuildVersionCodeplatformBuildVersionNamemanifestbrut.apktool.testapp1.021APKTOOL
obviously , We can't edit or view the compiled file . So how do we change the content ?
That this is apktool Where it works .
$ apktool d testapp.apk
I: Using Apktool 2.0.0 on testapp.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: 1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
$
AndroidManifest.xml Look again , Is that familiar . This is not in AS It's the same as the one shown inside !
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android" package="brut.apktool.testapp" platformBuildVersionCode="21" platformBuildVersionName="APKTOOL" />
except XML outside , Such as 9.PNG, Layout file , Strings and other resources , They are also correctly decoded into readable format .
decode ( Decompile )
apktool Besides being able to decode apk Outside , It can also decode jar file , Using parameter d or decode Of , The specific usage is as follows .
// take foo.jar Decode to foo.jar.out Folder
$ apktool d foo.jar
// The execution result is the same as the previous command
$ apktool decode foo.jar
// Decompile apk file , The generated file is in the... Of the current folder bar Catalog
$ apktool d bar.apk
// -o Parameter can specify the generated folder directory name
$ apktool d bar.apk -o baz
Examples of operation :

build( compile )
It can be seen from the b or build As shown below Call build options
// take foo.jar.out Folder build to foo.jar.out/dist/foo.jar In file
// Note the generated jar File path
$ apktool b foo.jar.out
$ apktool build foo.jar.out
// take bar Folder build apk To bar/dist/bar.apk In file
$ apktool b bar
// Build the current directory to ./dist in
$ apktool b .
// take bar Folder build to new_bar.apk in ,-o Options
$ apktool b bar -o new_bar.apk
// If you use the wrong file , The following error message appears .
$ apktool b bar.apk
// WRONG: brut.androlib.AndrolibException: brut.directory.PathNotExist: apktool.yml
// Must use folder, not apk/jar file

Recoiled apk, Cannot directly install and run . Need to sign again , Specific reference Android Developing documents
We execute the validation command , Check the... In the above example apk, Show app unsigned .

Manually sign the application from the command line
Here is already ready-made apk file , For in AndroidStudio Use the command line to build apk, Reference resources Build your application from the command line .
There are two options for signing applications from the command line jarsigner and apksigner.
Here are google Ways to recommend .
Signature APK , Refer to the following steps to use zipalign and apksigner.
- Open the command line ( stay Android Studio in , choice View > Tool Windows > Terminal ), Then navigate to unsigned APK directory .
- Use zipalign Align unsigned APK
zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
zipalign You can ensure that all uncompressed data is first aligned with a specific byte relative to the beginning of the file , Designated here 4 Byte alignment . This can reduce the amount of memory used by applications .

- Use apksigner Sign your with your private key APK:
apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
- In this case , Use a single keystore file my-release-key.jks Private key and certificate signing stored in APK after , With my-app-release.apk Form output signed APK .
apksigner The tool supports other signing options , This includes signing with a separate private key and certificate file APK file , And signed by more than one signatory APK. For more information , see also apksigner Reference resources .
notes : To use apksigner Tools , Must install Android SDK Build a revised version of the tool 24.0.3 Or later . You can use SDK Manager Update this package .

After executing the command, enter the password corresponding to the signature file , Check again whether the signature is successful .
- verification APK Whether it has been successfully signed , Execute the following command :
apksigner verify my-app-release.apk
Reference resources :
apktool Official documents
边栏推荐
- Muke.com actual combat course
- Tensorflow visualization tensorboard "no graph definition files were found." error
- One of token passing between microservices @feign's token passing
- 百度API地图的标注不是居中显示,而是显示在左上角是怎么回事?已解决!
- Second day of deep learning and tensorfow
- Collections and dictionaries
- [unity3d] human computer interaction input
- tensorlow:cifar100_ train
- Comment enregistrer une image dans une applet Wechat
- 创建 SSH 秘钥对 配置步骤
猜你喜欢

Wechat applet exits the applet (navigator and api--wx.exitminiprogram)

Image translation /gan:unsupervised image-to-image translation with self attention networks

Classic theory: detailed explanation of three handshakes and four waves of TCP protocol

Beidou navigation technology and industrial application of "chasing dreams in space and feeling for Beidou"

【Unity3D】碰撞体组件Collider

86.(cesium篇)cesium叠加面接收阴影效果(gltf模型)

Implementation of IM message delivery guarantee mechanism (II): ensure reliable delivery of offline messages

Windows下安装Tp6.0框架,图文。Thinkphp6.0安装教程

Zuul 实现动态路由

Second day of deep learning and tensorfow
随机推荐
AD教程系列 | 4 - 创建集成库文件
Statsmodels Library -- linear regression model
Briefly describe the pitfalls of mobile IM development: architecture design, communication protocol and client
How MySQL deletes all redundant duplicate data
《财富自由之路》读书之一点体会
Cookie and session Basics
date_ Range creation date range freq parameter value table and creation example
How to select the data transmission format of instant messaging application
YOLOv5-6.0的一些参数设置和特征图可视化
ThreadPoolExecutor实现文件上传批量插入数据
Introduction to classification data cotegory and properties and methods of common APIs
PHP one sentence Trojan horse
tensorlow:cifar100_ train
钟珊珊:被爆锤后的工程师会起飞|OneFlow U
YOLOV5训练结果的解释
Comment enregistrer une image dans une applet Wechat
Create a binary response variable using the cut sub box operation
Guanghetong and anti international bring 5g R16 powerful performance to the AI edge computing platform based on NVIDIA Jetson Xavier nx
Practical cases | getting started and mastering tkinter+pyinstaller
[IDE(ImageBed)]Picgo+Typora+aliyunOSS部署博客图床(2022.6)