I often compare my new build apk size with the production build and I am looking for options to automate this activity such that it compares both new and prod apk sizes and reports me. I am aware of APK Analyzer of Android Studio but I want to do that using command-line tools. This doc lists the usage of apkanalyzer but upon running this command
apkanalyzer -h apk file-size myapk.apk
It says "'apkanalyzer' is not recognized as an internal or external command, operable program or batch file." though I have already set the environment path to \Android\sdk\tools\bin.
Not sure why command-line is not recognizing this command, could you let me know where I could possibly have gone wrong or is there any other way to check apk file size using command-line?
Thanks for any help in advance.
This means that
apkanalyzer
does not exist in your SDK path.To download it, just got to SDK Manager and click on Android SDK Tools, then click Ok to continue and download the missing tools.
SDK manager
I've submitted a bug report to Google: https://issuetracker.google.com/issues/124064881
Apparently it's broken on Windows.
As others have mentioned, make sure you have installed the Android SDK Tools via the SDK Manager. They should show up in
<your_sdk_root>/tools/bin
. A long time ago I added<your_sdk_root>/tools
to my$PATH
in my ~/.bash_profile, but never added<your_sdk_root>/tools/bin
; apparently I missed the note that as of SDK Tools, Revision 25.3.0 tools were deprecated or otherwise moved to there among other places.Seee also https://developer.android.com/studio/command-line/ for details on the regular Tools, Build, Platform, and Emulator tools.
The apkanalyzer file (with no extension) in my sdk>tools>bin installed on my windows 10 pc is a Unix Shell script. Windows doesn't recognize this file as a valid command.
This appears to be a bug in the windows install of the Android SDK Tools 26.1.1.
apkanalyzer
is unix shell script, here converted batch script for windows, make sure to changeAPP_HOME
andCLASSPATH
to match your setup. save it asapkanalyzer.cmd
APK Analyzer tool is available in android studio https://developer.android.com/studio/build/apk-analyzer.html.
Most the command executable options can be used just with the good UI available in the Android Studio.