注意
apkanalyzer命令在 AndroidSDK安装目录\tools\bin下,需要使用linux命令行才可以执行。git带的git bash也可以。
https://developer.android.google.cn/studio/command-line/apkanalyzer
如果要在windows 命令行窗口执行apkanalyzer,有以下两种方式
方式一、使用下面这个文件
SDK\cmdline-tools\latest\bin\apkanalyzer.bat
方式二、自己搞一个apkanalyzer.bat,内容如下
@echo off
::##############################################################################
::##
::## apkanalyzer start up script for Windows
::##
::## converted by ewwink
::##
::##############################################################################
::Attempt to set APP_HOME
SET SAVED=%cd%
SET APP_HOME=%ANDROID_HOME%\tools
SET APP_NAME="apkanalyzer"
::Add default JVM options here. You can also use JAVA_OPTS and APKANALYZER_OPTS to pass JVM options to this script.
SET DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%APP_HOME%
SET CLASSPATH=%APP_HOME%\lib\dvlib-26.0.0-dev.jar;%APP_HOME%\lib\util-2.2.1.jar;%APP_HOME%\lib\jimfs-1.1.jar;%APP_HOME%\lib\annotations-13.0.jar;%APP_HOME%\lib\ddmlib-26.0.0-dev.jar;%APP_HOME%\lib\repository-26.0.0-dev.jar;%APP_HOME%\lib\sdk-common-26.0.0-dev.jar;%APP_HOME%\lib\kotlin-stdlib-1.1.3-2.jar;%APP_HOME%\lib\protobuf-java-3.0.0.jar;%APP_HOME%\lib\apkanalyzer-cli.jar;%APP_HOME%\lib\gson-2.3.jar;%APP_HOME%\lib\httpcore-4.2.5.jar;%APP_HOME%\lib\dexlib2-2.2.1.jar;%APP_HOME%\lib\commons-compress-1.12.jar;%APP_HOME%\lib\generator.jar;%APP_HOME%\lib\error_prone_annotations-2.0.18.jar;%APP_HOME%\lib\commons-codec-1.6.jar;%APP_HOME%\lib\kxml2-2.3.0.jar;%APP_HOME%\lib\httpmime-4.1.jar;%APP_HOME%\lib\annotations-12.0.jar;%APP_HOME%\lib\bcpkix-jdk15on-1.56.jar;%APP_HOME%\lib\jsr305-3.0.0.jar;%APP_HOME%\lib\explainer.jar;%APP_HOME%\lib\builder-model-3.0.0-dev.jar;%APP_HOME%\lib\baksmali-2.2.1.jar;%APP_HOME%\lib\j2objc-annotations-1.1.jar;%APP_HOME%\lib\layoutlib-api-26.0.0-dev.jar;%APP_HOME%\lib\jcommander-1.64.jar;%APP_HOME%\lib\commons-logging-1.1.1.jar;%APP_HOME%\lib\annotations-26.0.0-dev.jar;%APP_HOME%\lib\builder-test-api-3.0.0-dev.jar;%APP_HOME%\lib\animal-sniffer-annotations-1.14.jar;%APP_HOME%\lib\bcprov-jdk15on-1.56.jar;%APP_HOME%\lib\httpclient-4.2.6.jar;%APP_HOME%\lib\common-26.0.0-dev.jar;%APP_HOME%\lib\jopt-simple-4.9.jar;%APP_HOME%\lib\sdklib-26.0.0-dev.jar;%APP_HOME%\lib\apkanalyzer.jar;%APP_HOME%\lib\shared.jar;%APP_HOME%\lib\binary-resources.jar;%APP_HOME%\lib\guava-22.0.jar
SET APP_ARGS=%*
::Collect all arguments for the java command, following the shell quoting and substitution rules
SET APKANALYZER_OPTS=%DEFAULT_JVM_OPTS% -classpath %CLASSPATH% com.android.tools.apk.analyzer.ApkAnalyzerCli %APP_ARGS%
::Determine the Java command to use to start the JVM.
SET JAVACMD="java"
where %JAVACMD% >nul 2>nul
if %errorlevel%==1 (
echo ERROR: 'java' command could be found in your PATH.
echo Please set the 'java' variable in your environment to match the
echo location of your Java installation.
echo.
exit /b 0
)
:: execute apkanalyzer
%JAVACMD% %APKANALYZER_OPTS%
- 打印apk中Manifest文件中的内容
apkanalyzer manifest print XX.apk
- 打印apk的包名
apkanalyzer manifest application-id XX.apk
- 官方解释
$ apkanalyzer
Subject must be one of: apk, files, manifest, dex, resources
apk summary Prints the application Id, version code and version name.
apk file-size Prints the file size of the APK.
apk download-size Prints an estimate of the download size of the APK.
apk features Prints features used by the APK.
apk compare Compares the sizes of two APKs.
files list Lists all files in the zip.
files cat Prints the given file contents to stdout
manifest print Prints the manifest in XML format
manifest application-id Prints the application id.
manifest version-name Prints the version name.
manifest version-code Prints the version code.
manifest min-sdk Prints the minimum sdk.
manifest target-sdk Prints the target sdk
manifest permissions Prints a list of used permissions
manifest debuggable Prints if the app is debuggable
dex list Prints a list of dex files in the APK
dex references Prints number of references in dex files
dex packages Prints the class tree from DEX.
P,C,M,F: indicates
packages, classes methods, fields
x,k,r,d: indicates
removed, kept, referenced and defined nodes
dex code Prints the bytecode of a class or method in smali format
resources packages Prints a list of packages in resources table
resources configs Prints a list of configurations for a type
resources value Prints the given resource's value
resources names Prints a list of resource names for a type
resources xml Prints the human readable form of a binary XML
Usage:
apkanalyzer [global options] <subject> <verb> [options] <apk> [<apk2>]
Option Description
------ -----------
--human-readable Print sizes in human readable format
网友评论