Android 命令行工具-apkanalyzer

https://blog.csdn.net/iEearth/article/details/84589858

文章目录

 

apkanalyzer,从名字就可以看出这是一个分析apk的工具,最简单的使用方法是在AndroidStudio中点击Build,然后选择Analyze APK...,本文介绍如何在命令行使用apkanalyzer。

apkanalyzer在Android SDK中,位置为android_sdk/tools/bin/apkanalyzer
apkanalyzer的语法如下:

apkanalyzer [global-options] subject verb [options] apk-file [apk-file2]
  • 1
  • global-options:可选项,- -human-readable,可缩写为-h,表示以可读性好的格式打印文件大小。
  • subject:必选项,包括apk、files、manifest、dex、resources。
  • verb:必选项,根据subject的不同而不同。
  • options:可选项,根据subject和verb的不同而不同。
  • apk-file:必选项,表示需要分析的apk。
  • apk-file2:仅在比较两个apk时才需要。

下面详细说明apkanalyzer的用法。

1 打印App ID、版本信息

apkanalyzer apk summary apk-file

$ ./apkanalyzer apk summary Animal.apk 
a.b.animal	27	8.1.0
  • 1
  • 2
  • 3
  • 4

2 打印apk的文件大小

apkanalyzer apk file-size apk-file

$ ./apkanalyzer apk file-size Animal.apk 
376139
  • 1
  • 2
  • 3
  • 4

3 打印apk的download大小

apkanalyzer apk download-size apk-file

$ ./apkanalyzer apk download-size Animal.apk 
369340
  • 1
  • 2
  • 3
  • 4

4 打印apk用到的feature

apkanalyzer apk features [options] apk-file
options包括:--not-required

$ ./apkanalyzer apk features Animal.apk 
android.hardware.faketouch implied: default feature for all apps
  • 1
  • 2
  • 3
  • 4
  • 5

5 比较两个apk的大小

apkanalyzer apk compare [options] apk-file apk-file2
options包括:--different-only、--files-only、--patch-size

$ ./apkanalyzer apk compare Animal.apk Animal2.apk 
376139	301359	-74780	/
8804	8828	24	/classes.dex
6192	6192	0	/META-INF/
2191	2191	0	/META-INF/MANIFEST.MF
1722	1722	0	/META-INF/CERT.RSA
2279	2279	0	/META-INF/CERT.SF
2764	2764	0	/AndroidManifest.xml
4112	4112	0	/resources.arsc
367539	292731	-74808	/res/
1104	1104	0	/res/mipmap-anydpi-v26/
552	552	0	/res/mipmap-anydpi-v26/ic_launcher_round.xml
552	552	0	/res/mipmap-anydpi-v26/ic_launcher.xml
1208	1208	0	/res/layout/
1208	1208	0	/res/layout/layout_main.xml
3416	3416	0	/res/drawable-v24/
760	760	0	/res/drawable-v24/ic_launcher_foreground_1.xml
2656	2656	0	/res/drawable-v24/ic_launcher_foreground.xml
25133	25133	0	/res/mipmap-xxxhdpi-v4/
16187	16187	0	/res/mipmap-xxxhdpi-v4/ic_launcher_round.png
8946	8946	0	/res/mipmap-xxxhdpi-v4/ic_launcher.png
18161	18161	0	/res/mipmap-xxhdpi-v4/
11607	11607	0	/res/mipmap-xxhdpi-v4/ic_launcher_round.png
6554	6554	0	/res/mipmap-xxhdpi-v4/ic_launcher.png
12680	12680	0	/res/mipmap-xhdpi-v4/
8004	8004	0	/res/mipmap-xhdpi-v4/ic_launcher_round.png
4676	4676	0	/res/mipmap-xhdpi-v4/ic_launcher.png
5816	5816	0	/res/mipmap-mdpi-v4/
3487	3487	0	/res/mipmap-mdpi-v4/ic_launcher_round.png
2329	2329	0	/res/mipmap-mdpi-v4/ic_launcher.png
9165	9165	0	/res/mipmap-hdpi-v4/
5843	5843	0	/res/mipmap-hdpi-v4/ic_launcher_round.png
3322	3322	0	/res/mipmap-hdpi-v4/ic_launcher.png
290856	216048	-74808	/res/drawable/
6280	6280	0	/res/drawable/ic_launcher_background.xml
284576	209768	-74808	/res/drawable/animal.jpg
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39

6 打印apk中的文件列表

apkanalyzer files list apk-file

$ ./apkanalyzer files list Animal.apk 
/
/META-INF/
/META-INF/MANIFEST.MF
/META-INF/CERT.RSA
/META-INF/CERT.SF
/classes.dex
/AndroidManifest.xml
/resources.arsc
/res/
/res/mipmap-anydpi-v26/
/res/mipmap-anydpi-v26/ic_launcher_round.xml
/res/mipmap-anydpi-v26/ic_launcher.xml
/res/layout/
/res/layout/layout_main.xml
/res/drawable-v24/
/res/drawable-v24/ic_launcher_foreground_1.xml
/res/drawable-v24/ic_launcher_foreground.xml
/res/mipmap-xxxhdpi-v4/
/res/mipmap-xxxhdpi-v4/ic_launcher_round.png
/res/mipmap-xxxhdpi-v4/ic_launcher.png
/res/mipmap-xxhdpi-v4/
/res/mipmap-xxhdpi-v4/ic_launcher_round.png
/res/mipmap-xxhdpi-v4/ic_launcher.png
/res/mipmap-xhdpi-v4/
/res/mipmap-xhdpi-v4/ic_launcher_round.png
/res/mipmap-xhdpi-v4/ic_launcher.png
/res/mipmap-mdpi-v4/
/res/mipmap-mdpi-v4/ic_launcher_round.png
/res/mipmap-mdpi-v4/ic_launcher.png
/res/mipmap-hdpi-v4/
/res/mipmap-hdpi-v4/ic_launcher_round.png
/res/mipmap-hdpi-v4/ic_launcher.png
/res/drawable/
/res/drawable/ic_launcher_background.xml
/res/drawable/animal.jpg
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

7 打印apk中某个文件的内容(二进制内容会原样显示)

apkanalyzer files cat --file path apk-file

$ ./apkanalyzer files cat --file /AndroidManifest.xml Animal.apk 
�
�'�6Pn������,:L����"6Nv����l�8Pd�����
                                                                       sharedUserId
                                                                                   versionCode
minSdkVersiontargetSdkVersionname                                                           versionName
                                   allowBackuphardwareAcceleratediconlabel	roundIcon
                                                                                         supportsRtlthemeandroid*http://schemas.android.com/apk/res/androidpackageplatformBuildVersionCodeplatformBuildVersionNammanifest
a.b.animalandroid.uid.system8.1.02uses-sdkuses-permission'android.permission.MODIFY_THEME_OVERLAY*android.permission.CHANGE_OVERLAY_PACKAGES(android.permission.INTERACT_ACROSS_USERS-android.permission.INTERACT_ACROSS_USERS_FULL
                                              application
intent-filteractionandroid.intent.action.MAIcategoryandroid.intent.category.DEFAULT�<
                                                                                        
������������������������L����������������������8����������������8��������������������������������8	��������	���������
                                             ��������
                                                       ���	��������������������
                                                                                            �������
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

8 打印AndroidManifest.xml(文本格式)

apkanalyzer manifest print apk-file

$ ./apkanalyzer manifest print Animal.apk 
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:sharedUserId="android.uid.system"
    android:versionCode="27"
    android:versionName="8.1.0"
    package="a.b.animal"
    platformBuildVersionCode="27"
    platformBuildVersionName="8.1.0">

    <uses-sdk
        android:minSdkVersion="27"
        android:targetSdkVersion="27" />

    <uses-permission
        android:name="android.permission.MODIFY_THEME_OVERLAY" />

    <uses-permission
        android:name="android.permission.CHANGE_OVERLAY_PACKAGES" />

    <uses-permission
        android:name="android.permission.INTERACT_ACROSS_USERS" />

    <uses-permission
        android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />

    <application
        android:theme="@ref/0x7f070000"
        android:label="@ref/0x7f060000"
        android:icon="@ref/0x7f030000"
        android:name=".AnimalApp"
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:supportsRtl="true"
        android:roundIcon="@ref/0x7f030001">

        <activity
            android:name=".MainActivity">

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53

9 打印App ID

apkanalyzer manifest application-id apk-file

$ ./apkanalyzer manifest application-id Animal.apk 
a.b.animal
  • 1
  • 2
  • 3
  • 4

10 打印版本名

apkanalyzer manifest version-name apk-file

$ ./apkanalyzer manifest version-name Animal.apk 
8.1.0
  • 1
  • 2
  • 3
  • 4

11 打印版本号

apkanalyzer manifest version-code apk-file

$ ./apkanalyzer manifest version-code Animal.apk 
27
  • 1
  • 2
  • 3
  • 4

12 打印最低的SDK版本

apkanalyzer manifest min-sdk apk-file

$ ./apkanalyzer manifest min-sdk Animal.apk 
27
  • 1
  • 2
  • 3
  • 4

13 打印目标SDK版本

apkanalyzer manifest target-sdk apk-file

$ ./apkanalyzer manifest target-sdk Animal.apk 
27
  • 1
  • 2
  • 3
  • 4

14 打印用到的权限列表

apkanalyzer manifest permissions apk-file

$ ./apkanalyzer manifest permissions Animal.apk 
android.permission.CHANGE_OVERLAY_PACKAGES
android.permission.MODIFY_THEME_OVERLAY
android.permission.INTERACT_ACROSS_USERS_FULL
android.permission.INTERACT_ACROSS_USERS
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

15 打印是否debug模式

apkanalyzer manifest debuggable apk-file

$ ./apkanalyzer manifest debuggable Animal.apk 
false
  • 1
  • 2
  • 3
  • 4

16 打印apk中的dex文件列表

apkanalyzer dex list apk-file

$ ./apkanalyzer dex list Animal.apk 
classes.dex
  • 1
  • 2
  • 3
  • 4

17 打印dex文件中引用的方法个数(默认打印所有的dex文件)

apkanalyzer dex references [--files path] [--files path2] apk-file

$ ./apkanalyzer dex references Animal.apk 
classes.dex	64
  • 1
  • 2
  • 3
  • 4

18 打印dex文件中的类信息

apkanalyzer dex packages [option1 option2 ...] apk-file
options包括:--defined-only、--files、--proguard-folder file、--proguard-mappings file、--proguard-seeds file、--proguard-usages file、--show-removed

$ ./apkanalyzer dex packages Animal.apk 
P d 28	64	5214	<TOTAL>
P d 28	31	4448	a
P d 28	31	4448	a.b
P d 28	31	4448	a.b.animal
C d 9	12	1136	a.b.animal.MainActivity
M d 1	1	58	a.b.animal.MainActivity int -get0(a.b.animal.MainActivity)
M d 1	1	58	a.b.animal.MainActivity android.content.om.IOverlayManager -get1(a.b.animal.MainActivity)
M d 1	1	55	a.b.animal.MainActivity <init>()
M d 1	1	453	a.b.animal.MainActivity void onCreate(android.os.Bundle)
M d 1	1	74	a.b.animal.MainActivity void onDestroy()
M d 1	1	73	a.b.animal.MainActivity void onPause()
M d 1	1	73	a.b.animal.MainActivity void onResume()
M d 1	1	73	a.b.animal.MainActivity void onStart()
M d 1	1	74	a.b.animal.MainActivity void onStop()
M r 0	1	26	a.b.animal.MainActivity android.view.View findViewById(int)
M r 0	1	20	a.b.animal.MainActivity android.content.res.Resources getResources()
M r 0	1	26	a.b.animal.MainActivity void setContentView(int)
F d 0	0	12	a.b.animal.MainActivity java.lang.String TAG
F d 0	0	10	a.b.animal.MainActivity int mCurrentUserId
F d 0	0	10	a.b.animal.MainActivity android.content.om.IOverlayManager mOverlayManager
C d 4	4	369	a.b.animal.AnimalApp
M d 1	1	75	a.b.animal.AnimalApp <init>()
M d 1	1	109	a.b.animal.AnimalApp void onConfigurationChanged(android.content.res.Configuration)
M d 1	1	66	a.b.animal.AnimalApp void onCreate()
M d 1	1	66	a.b.animal.AnimalApp void onTerminate()
F d 0	0	12	a.b.animal.AnimalApp java.lang.String TAG
C d 2	2	620	a.b.animal.MainActivity$1
M d 1	1	73	a.b.animal.MainActivity$1 <init>(a.b.animal.MainActivity)
M d 1	1	462	a.b.animal.MainActivity$1 void onClick(android.view.View)
F d 0	0	11	a.b.animal.MainActivity$1 a.b.animal.MainActivity this$0
C d 2	2	479	a.b.animal.MainActivity$2
M d 1	1	75	a.b.animal.MainActivity$2 <init>(a.b.animal.MainActivity)
M d 1	1	319	a.b.animal.MainActivity$2 void onClick(android.view.View)
F d 0	0	11	a.b.animal.MainActivity$2 a.b.animal.MainActivity this$0
C d 2	2	479	a.b.animal.MainActivity$3
M d 1	1	75	a.b.animal.MainActivity$3 <init>(a.b.animal.MainActivity)
M d 1	1	319	a.b.animal.MainActivity$3 void onClick(android.view.View)
F d 0	0	11	a.b.animal.MainActivity$3 a.b.animal.MainActivity this$0
C d 1	1	123	a.b.animal.R$attr
M d 1	1	55	a.b.animal.R$attr <init>()
C d 1	1	139	a.b.animal.R$color
M d 1	1	55	a.b.animal.R$color <init>()
F d 0	0	15	a.b.animal.R$color int color_default
C d 1	1	184	a.b.animal.R$drawable
M d 1	1	55	a.b.animal.R$drawable <init>()
F d 0	0	15	a.b.animal.R$drawable int animal
F d 0	0	15	a.b.animal.R$drawable int ic_launcher_background
F d 0	0	15	a.b.animal.R$drawable int ic_launcher_foreground
F d 0	0	15	a.b.animal.R$drawable int ic_launcher_foreground_1
C d 1	1	184	a.b.animal.R$id
M d 1	1	55	a.b.animal.R$id <init>()
F d 0	0	15	a.b.animal.R$id int image_animal
F d 0	0	15	a.b.animal.R$id int theme_default
F d 0	0	15	a.b.animal.R$id int theme_dog
F d 0	0	15	a.b.animal.R$id int theme_monkey
C d 1	1	139	a.b.animal.R$layout
M d 1	1	55	a.b.animal.R$layout <init>()
F d 0	0	15	a.b.animal.R$layout int layout_main
C d 1	1	154	a.b.animal.R$mipmap
M d 1	1	55	a.b.animal.R$mipmap <init>()
F d 0	0	15	a.b.animal.R$mipmap int ic_launcher
F d 0	0	15	a.b.animal.R$mipmap int ic_launcher_round
C d 1	1	184	a.b.animal.R$string
M d 1	1	55	a.b.animal.R$string <init>()
F d 0	0	15	a.b.animal.R$string int app_name
F d 0	0	15	a.b.animal.R$string int theme_default
F d 0	0	15	a.b.animal.R$string int theme_dog
F d 0	0	15	a.b.animal.R$string int theme_monkey
C d 1	1	139	a.b.animal.R$style
M d 1	1	55	a.b.animal.R$style <init>()
F d 0	0	15	a.b.animal.R$style int AppTheme
C d 1	1	119	a.b.animal.R
M d 1	1	55	a.b.animal.R <init>()
P r 0	18	430	android
P r 0	9	186	android.app
C r 0	7	146	android.app.Activity
M r 0	1	20	android.app.Activity <init>()
M r 0	1	26	android.app.Activity void onCreate(android.os.Bundle)
M r 0	1	20	android.app.Activity void onDestroy()
M r 0	1	20	android.app.Activity void onPause()
M r 0	1	20	android.app.Activity void onResume()
M r 0	1	20	android.app.Activity void onStart()
M r 0	1	20	android.app.Activity void onStop()
C r 0	1	20	android.app.ActivityManager
M r 0	1	20	android.app.ActivityManager int getCurrentUser()
C r 0	1	20	android.app.Application
M r 0	1	20	android.app.Application <init>()
P r 0	4	108	android.content
P r 0	3	82	android.content.om
C r 0	2	56	android.content.om.IOverlayManager
M r 0	1	26	android.content.om.IOverlayManager java.util.Map getAllOverlays(int)
M r 0	1	30	android.content.om.IOverlayManager boolean setEnabledExclusive(java.lang.String,boolean,int)
C r 0	1	26	android.content.om.IOverlayManager$Stub
M r 0	1	26	android.content.om.IOverlayManager$Stub android.content.om.IOverlayManager asInterface(android.os.IBinder)
P r 0	1	26	android.content.res
C r 0	1	26	android.content.res.Resources
M r 0	1	26	android.content.res.Resources int getColor(int)
P r 0	2	58	android.util
C r 0	2	58	android.util.Log
M r 0	1	28	android.util.Log int d(java.lang.String,java.lang.String)
M r 0	1	30	android.util.Log int w(java.lang.String,java.lang.String,java.lang.Throwable)
P r 0	2	52	android.widget
C r 0	2	52	android.widget.Button
M r 0	1	26	android.widget.Button void setBackgroundColor(int)
M r 0	1	26	android.widget.Button void setOnClickListener(android.view.View$OnClickListener)
P r 0	1	26	android.os
C r 0	1	26	android.os.ServiceManager
M r 0	1	26	android.os.ServiceManager android.os.IBinder getService(java.lang.String)
P r 0	15	336	java
P r 0	8	184	java.lang
C r 0	6	144	java.lang.StringBuilder
M r 0	1	20	java.lang.StringBuilder <init>()
M r 0	1	26	java.lang.StringBuilder java.lang.StringBuilder append(int)
M r 0	1	26	java.lang.StringBuilder java.lang.StringBuilder append(java.lang.Object)
M r 0	1	26	java.lang.StringBuilder java.lang.StringBuilder append(java.lang.String)
M r 0	1	26	java.lang.StringBuilder java.lang.StringBuilder append(boolean)
M r 0	1	20	java.lang.StringBuilder java.lang.String toString()
C r 0	1	20	java.lang.Object
M r 0	1	20	java.lang.Object <init>()
C r 0	1	20	java.lang.Iterable
M r 0	1	20	java.lang.Iterable java.util.Iterator iterator()
P r 0	7	152	java.util
C r 0	3	66	java.util.Map
M r 0	1	26	java.util.Map java.lang.Object get(java.lang.Object)
M r 0	1	20	java.util.Map boolean isEmpty()
M r 0	1	20	java.util.Map java.util.Set keySet()
C r 0	2	40	java.util.Iterator
M r 0	1	20	java.util.Iterator boolean hasNext()
M r 0	1	20	java.util.Iterator java.lang.Object next()
C r 0	2	46	java.util.List
M r 0	1	26	java.util.List java.lang.Object get(int)
M r 0	1	20	java.util.List int size()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136

19 打印类的字节码或者方法的反编译格式

apkanalyzer dex code --class class [--method method]

$ ./apkanalyzer dex code --class a.b.animal.MainActivity Animal.apk 
.class public La/b/animal/MainActivity;
.super Landroid/app/Activity;
.source "MainActivity.java"


# static fields
.field private static final TAG:Ljava/lang/String; = "Animal"


# instance fields
.field private mCurrentUserId:I

.field private mOverlayManager:Landroid/content/om/IOverlayManager;


# direct methods
.method static synthetic -get0(La/b/animal/MainActivity;)I
    .registers 2
    .param p0, "-this"    # La/b/animal/MainActivity;

    .prologue
    iget v0, p0, La/b/animal/MainActivity;->mCurrentUserId:I

    return v0
.end method

.method static synthetic -get1(La/b/animal/MainActivity;)Landroid/content/om/IOverlayManager;
    .registers 2
    .param p0, "-this"    # La/b/animal/MainActivity;

    .prologue
    iget-object v0, p0, La/b/animal/MainActivity;->mOverlayManager:Landroid/content/om/IOverlayManager;

    return-object v0
.end method

.method public constructor <init>()V
    .registers 1

    .prologue
    .line 19
    invoke-direct {p0}, Landroid/app/Activity;-><init>()V

    return-void
.end method


# virtual methods
.method protected onCreate(Landroid/os/Bundle;)V
    .registers 9
    .param p1, "savedInstanceState"    # Landroid/os/Bundle;

    .prologue
    const/high16 v6, 0x7f050000

    .line 27
    const-string/jumbo v3, "Animal"

    const-string/jumbo v4, "onCreate"

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 29
    invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

    .line 31
    const/high16 v3, 0x7f040000

    invoke-virtual {p0, v3}, La/b/animal/MainActivity;->setContentView(I)V

    .line 33
    invoke-static {}, Landroid/app/ActivityManager;->getCurrentUser()I

    move-result v3

    iput v3, p0, La/b/animal/MainActivity;->mCurrentUserId:I

    .line 34
    const-string/jumbo v3, "Animal"

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v5, "CurrentUser "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    iget v5, p0, La/b/animal/MainActivity;->mCurrentUserId:I

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 37
    const-string/jumbo v3, "overlay"

    invoke-static {v3}, Landroid/os/ServiceManager;->getService(Ljava/lang/String;)Landroid/os/IBinder;

    move-result-object v3

    .line 36
    invoke-static {v3}, Landroid/content/om/IOverlayManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/content/om/IOverlayManager;

    move-result-object v3

    iput-object v3, p0, La/b/animal/MainActivity;->mOverlayManager:Landroid/content/om/IOverlayManager;

    .line 38
    const-string/jumbo v3, "Animal"

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v5, "OverlayManager "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    iget-object v5, p0, La/b/animal/MainActivity;->mOverlayManager:Landroid/content/om/IOverlayManager;

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 40
    const v3, 0x7f080001

    invoke-virtual {p0, v3}, La/b/animal/MainActivity;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/Button;

    .line 41
    .local v0, "themeDefault":Landroid/widget/Button;
    invoke-virtual {p0}, La/b/animal/MainActivity;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    invoke-virtual {v3, v6}, Landroid/content/res/Resources;->getColor(I)I

    move-result v3

    invoke-virtual {v0, v3}, Landroid/widget/Button;->setBackgroundColor(I)V

    .line 42
    new-instance v3, La/b/animal/MainActivity$1;

    invoke-direct {v3, p0}, La/b/animal/MainActivity$1;-><init>(La/b/animal/MainActivity;)V

    invoke-virtual {v0, v3}, Landroid/widget/Button;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 69
    const v3, 0x7f080002

    invoke-virtual {p0, v3}, La/b/animal/MainActivity;->findViewById(I)Landroid/view/View;

    move-result-object v1

    check-cast v1, Landroid/widget/Button;

    .line 70
    .local v1, "themeDog":Landroid/widget/Button;
    invoke-virtual {p0}, La/b/animal/MainActivity;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    invoke-virtual {v3, v6}, Landroid/content/res/Resources;->getColor(I)I

    move-result v3

    invoke-virtual {v1, v3}, Landroid/widget/Button;->setBackgroundColor(I)V

    .line 71
    new-instance v3, La/b/animal/MainActivity$2;

    invoke-direct {v3, p0}, La/b/animal/MainActivity$2;-><init>(La/b/animal/MainActivity;)V

    invoke-virtual {v1, v3}, Landroid/widget/Button;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 88
    const v3, 0x7f080003

    invoke-virtual {p0, v3}, La/b/animal/MainActivity;->findViewById(I)Landroid/view/View;

    move-result-object v2

    check-cast v2, Landroid/widget/Button;

    .line 89
    .local v2, "themeMonkey":Landroid/widget/Button;
    invoke-virtual {p0}, La/b/animal/MainActivity;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    invoke-virtual {v3, v6}, Landroid/content/res/Resources;->getColor(I)I

    move-result v3

    invoke-virtual {v2, v3}, Landroid/widget/Button;->setBackgroundColor(I)V

    .line 90
    new-instance v3, La/b/animal/MainActivity$3;

    invoke-direct {v3, p0}, La/b/animal/MainActivity$3;-><init>(La/b/animal/MainActivity;)V

    invoke-virtual {v2, v3}, Landroid/widget/Button;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 106
    return-void
.end method

.method protected onDestroy()V
    .registers 3

    .prologue
    .line 134
    const-string/jumbo v0, "Animal"

    const-string/jumbo v1, "onDestroy"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 135
    invoke-super {p0}, Landroid/app/Activity;->onDestroy()V

    .line 136
    return-void
.end method

.method protected onPause()V
    .registers 3

    .prologue
    .line 122
    const-string/jumbo v0, "Animal"

    const-string/jumbo v1, "onPause"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 123
    invoke-super {p0}, Landroid/app/Activity;->onPause()V

    .line 124
    return-void
.end method

.method protected onResume()V
    .registers 3

    .prologue
    .line 116
    const-string/jumbo v0, "Animal"

    const-string/jumbo v1, "onResume"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 117
    invoke-super {p0}, Landroid/app/Activity;->onResume()V

    .line 118
    return-void
.end method

.method protected onStart()V
    .registers 3

    .prologue
    .line 110
    const-string/jumbo v0, "Animal"

    const-string/jumbo v1, "onStart"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 111
    invoke-super {p0}, Landroid/app/Activity;->onStart()V

    .line 112
    return-void
.end method

.method protected onStop()V
    .registers 3

    .prologue
    .line 128
    const-string/jumbo v0, "Animal"

    const-string/jumbo v1, "onStop"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 129
    invoke-super {p0}, Landroid/app/Activity;->onStop()V

    .line 130
    return-void
.end method
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321

20 打印资源表中的包

apkanalyzer resources packages apk-file

$ ./apkanalyzer resources packages Animal.apk 
a.b.animal
  • 1
  • 2
  • 3
  • 4

21 打印某个资源类型的配置

apkanalyzer resources configs --type type [--package package] apk-file

$ ./apkanalyzer resources configs --type string Animal.apk 
default
en-rXA
ar-rXB
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

22 打印某个资源的值

apkanalyzer resources value --config config --name name --type type [--package package] apk-file

$ ./apkanalyzer resources value --config default --name app_name --type string Animal.apk 
Animal
  • 1
  • 2
  • 3
  • 4

23 打印某种资源类型的所有名字

apkanalyzer resources names --config config --type type [--package package] apk-file

$ ./apkanalyzer resources names --config default --type string Animal.apk 
app_name
theme_default
theme_dog
theme_monkey
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

24 打印二进制xml文件(纯文本格式输出)

apkanalyzer resources xml --file path apk-file
$ ./apkanalyzer resources xml --file /AndroidManifest.xml Animal.apk 
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:sharedUserId="android.uid.system"
    android:versionCode="27"
    android:versionName="8.1.0"
    package="a.b.animal"
    platformBuildVersionCode="27"
    platformBuildVersionName="8.1.0">

    <uses-sdk
        android:minSdkVersion="27"
        android:targetSdkVersion="27" />

    <uses-permission
        android:name="android.permission.MODIFY_THEME_OVERLAY" />

    <uses-permission
        android:name="android.permission.CHANGE_OVERLAY_PACKAGES" />

    <uses-permission
        android:name="android.permission.INTERACT_ACROSS_USERS" />

    <uses-permission
        android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />

    <application
        android:theme="@ref/0x7f070000"
        android:label="@ref/0x7f060000"
        android:icon="@ref/0x7f030000"
        android:name=".AnimalApp"
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:supportsRtl="true"
        android:roundIcon="@ref/0x7f030001">

        <activity
            android:name=".MainActivity">

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52

参考:https://developer.android.com/studio/command-line/apkanalyzer

posted @ 2020-10-05 10:33  行走的思想  阅读(1394)  评论(0编辑  收藏  举报