Maria Sophia wrote:
Below is the latest version of apkanalyzer.bat as a result of this effort. I posted the before:after scripts to the Windows 11, Linux and macOS newsgroups in a separate set of posts, but for this thread, all we need is the final version, provided below, of the working apkanalyzer.bat script. Had I known how much work it turned out to be to port the Linux/macOS script to Windows, I likely wouldn't even have tried, since apksigner.bat tells us the cryptography when comparing APKs, and aapt/aapt2 tells us about the version differences, although certainly apkanalyzer does more. These are the fundamental APK debugging commands used in this process: C:\> apksigner.bat verify --print-certs base.apk C:\> aapt2.exe dump badging base.apk | findstr /C:"package:" C:\> apkanalyzer.bat manifest application-id base.apk C:\> apkanalyzer.bat manifest version-code base.apk :: -------------------------------------------------------------------- :: apkanalyzer.bat :: Conversion of Android sdk Linux/macOS apkanalyzer script to Windows :: -------------------------------------------------------------------- :: v2p1 20261022 Added aapt/aapt2 and apksigner.bat debugging examples :: v2p0 20261022 Made APP_HOME portable using dynamic-script-path resolution :: v1p9 20261022 Shortened CLASSPATH using wildcard and multiline execution :: v1p8 20261022 Split CLASSPATH to overcome 1K-characters-per-line limits :: v1p7 20261022 Added and tested example help command syntax above :: v1p6 20261022 Added and tested example command syntax above :: v1p5 20261022 Added jakarta.activation-api.jar to Windows and classpath :: v1p4 20261022 Added istack-commons-runtime.jar to Windows and classpath :: v1p3 20261022 Added jaxb-api-2.3.1.jar to Windows and classpath :: v1p2 20261022 Added jaxb-runtime-2.3.5.jar to Windows and classpath :: v1p1 20261022 Added variables to set custom paths to dependencies :: v1p0 20261022 Convert C:\app\editor\android\sdk\tools\bin\apkanalyzer :: -------------------------------------------------------------------- :: Tested on the base apk installed 20261022 using the commands below: :: C:\> curl.exe -L "https://www.whatsapp.com/android/current/WhatsApp.apk" :: C:\> adb -r WhatsApp.apk :: C:\> adb shell pm path com.whatsapp :: C:\> adb pull "... that path ... app-SuTfaV-YTnPJBe_GGlwL0w==/base.apk" :: -------------------------------------------------------------------- :: To use: :: C:\> apkanalyzer.bat manifest application-id base.apk :: C:\> apkanalyzer.bat manifest version-code base.apk :: C:\> apkanalyzer.bat manifest version-name base.apk :: C:\> apkanalyzer.bat manifest min-sdk base.apk :: C:\> apkanalyzer.bat manifest target-sdk base.apk :: C:\> apkanalyzer.bat manifest permissions base.apk :: C:\> apkanalyzer.bat manifest debuggable base.apk :: C:\> apkanalyzer.bat apk summary base.apk :: C:\> apkanalyzer.bat apk file-size base.apk :: C:\> apkanalyzer.bat apk download-size base.apk :: C:\> apkanalyzer.bat files list base.apk :: C:\> apkanalyzer.bat manifest print base.apk :: C:\> apkanalyzer.bat dex list base.apk :: C:\> apkanalyzer.bat dex references base.apk :: C:\> apkanalyzer.bat apk features base.apk :: C:\> apkanalyzer.bat files cat --file "AndroidManifest.xml" base.apk :: C:\> apkanalyzer.bat dex packages base.apk :: C:\> apkanalyzer.bat resources packages base.apk :: C:\> apkanalyzer.bat resources names --config default --type string base.apk :: C:\> apkanalyzer.bat files list base.apk | findstr /i "\.xml" :: C:\> apkanalyzer.bat resources xml --file "res/xml/splits0.xml" base.apk :: C:\> apkanalyzer.bat --help :: C:\> apkanalyzer.bat apk --help :: C:\> apkanalyzer.bat dex --help :: C:\> apkanalyzer.bat resources --help :: See also: :: C:\> apkanalyzer.bat files list base.apk :: C:\> apksigner.bat verify --print-certs base.apk :: C:\> apksigner.bat verify --verbose --print-certs base.apk :: C:\> aapt2.exe dump badging base.apk | findstr /C:"package:" :: C:\> aapt2.exe dump permissions base.apk :: C:\> aapt2.exe dump xmltree base.apk --file AndroidManifest.xml :: -------------------------------------------------------------------- @ECHO OFF setlocal REM Dynamically resolve Android SDK Tools Root Path from script location (\tools\bin\ -> \tools\) for %%I in ("%~dp0..") do set "APP_HOME=%%~fI" REM Custom OpenJDK 17 Path (Adjust if your Java path changes) set "JAVA_EXE=C:\Program Files\Microsoft\jdk-17.0.18.8-hotspot\bin\java.exe" REM All JARs in the SDK lib directory via wildcard set "CLASSPATH=%APP_HOME%\lib\*" "%JAVA_EXE%" "-Dcom.android.sdklib.toolsdir=%APP_HOME%" ^ -classpath "%CLASSPATH%" ^ com.android.tools.apk.analyzer.ApkAnalyzerCli %* endlocal :: end of apkanalyzer.bat
-- We learned a lot about how to debug and compare similar APKs.