Inspecting APKs: aapt2, apkanalyzer & unzip
An APK is a zip file with a known layout. Being able to open one and answer "what's in here?" without Android Studio is a core build-engineering skill: it's how you debug a store rejection, a size regression or a missing resource on CI.
app-release.apk
├── AndroidManifest.xml binary XML (the merged manifest)
├── classes.dex code (classes2.dex … for large apps)
├── resources.arsc compiled resource table
├── res/… compiled XML, images
├── lib/<abi>/*.so native libraries
├── assets/… raw files
└── META-INF/… v1 signature files, metadata
(+ the v2/v3 APK Signing Block, which isn't a zip entry at all)The three tools
| Tool | From | Best for |
|---|---|---|
unzip -l |
any system | file list and sizes |
aapt2 dump badging / permissions / resources / xmltree |
build-tools | the manifest and resource table, decoded |
apkanalyzer |
command-line tools | summaries, sizes, dex contents, comparing two APKs |
mkdir -p hello/app/src/main/java/com/example/hello hello/app/src/main/res/values && cd hello
cat > settings.gradle.kts <<'KTS'
pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
rootProject.name = "hello"
include(":app")
KTS
echo 'plugins { id("com.android.application") version "9.4.1" apply false }' > build.gradle.kts
cat > app/src/main/AndroidManifest.xml <<'XML'
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="@string/app_name">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
XML
echo '<resources><string name="app_name">Hello</string></resources>' > app/src/main/res/values/strings.xml
cat > app/src/main/java/com/example/hello/MainActivity.java <<'JAVA'
package com.example.hello;
public class MainActivity extends android.app.Activity {
@Override protected void onCreate(android.os.Bundle state) {
super.onCreate(state);
android.widget.TextView view = new android.widget.TextView(this);
view.setText(R.string.app_name);
setContentView(view);
}
}
JAVA
cat > app/build.gradle.kts <<'KTS'
plugins { id("com.android.application") }
android {
namespace = "com.example.hello"
compileSdk = 36
defaultConfig { applicationId = "com.example.hello"; minSdk = 24; targetSdk = 36; versionCode = 21; versionName = "2.1.0" }
buildTypes { release { isMinifyEnabled = true; proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) } }
}
KTS
gradle wrapper > /dev/null
./gradlew -q assembleRelease
APK=app/build/outputs/apk/release/app-release-unsigned.apk
echo "=== aapt2 dump badging"
aapt2 dump badging $APK | head -6
echo "=== aapt2 dump permissions"
aapt2 dump permissions $APK
echo "=== the binary manifest, decoded"
aapt2 dump xmltree --file AndroidManifest.xml $APK | head -8
echo "=== unzip -l"
unzip -l $APK=== aapt2 dump badging
package: name='com.example.hello' versionCode='21' versionName='2.1.0' platformBuildVersionName='16' platformBuildVersionCode='36' compileSdkVersion='36' compileSdkVersionCodename='16'
minSdkVersion:'24'
targetSdkVersion:'36'
uses-permission: name='android.permission.INTERNET'
application-label:'Hello'
application: label='Hello' icon=''
=== aapt2 dump permissions
package: com.example.hello
uses-permission: name='android.permission.INTERNET'
=== the binary manifest, decoded
N: android=http://schemas.android.com/apk/res/android (line=2)
E: manifest (line=2)
A: http://schemas.android.com/apk/res/android:versionCode(0x0101021b)=21
A: http://schemas.android.com/apk/res/android:versionName(0x0101021c)="2.1.0" (Raw: "2.1.0")
A: http://schemas.android.com/apk/res/android:compileSdkVersion(0x01010572)=36
A: http://schemas.android.com/apk/res/android:compileSdkVersionCodename(0x01010573)="16" (Raw: "16")
A: package="com.example.hello" (Raw: "com.example.hello")
A: platformBuildVersionCode=36
=== unzip -l
Archive: app/build/outputs/apk/release/app-release-unsigned.apk
Length Date Time Name
--------- ---------- ----- ----
56 1981-01-01 01:01 META-INF/com/android/build/gradle/app-metadata.properties
46 1981-01-01 01:01 META-INF/version-control-info.textproto
1128 1981-01-01 01:01 classes.dex
1006 1981-01-01 01:01 kotlin/annotation/annotation.kotlin_builtins
8308 1981-01-01 01:01 kotlin/collections/collections.kotlin_builtins
2674 1981-01-01 01:01 kotlin/concurrent/atomics/atomics.kotlin_builtins
137 1981-01-01 01:01 kotlin/coroutines/coroutines.kotlin_builtins
590 1981-01-01 01:01 kotlin/internal/internal.kotlin_builtins
29399 1981-01-01 01:01 kotlin/kotlin.kotlin_builtins
4184 1981-01-01 01:01 kotlin/ranges/ranges.kotlin_builtins
4827 1981-01-01 01:01 kotlin/reflect/reflect.kotlin_builtins
2068 1981-01-01 01:01 AndroidManifest.xml
556 1981-01-01 01:01 resources.arsc
--------- -------
54979 13 files
badging is the quickest way to confirm what a CI job built: package name, version, SDK levels and permissions on a few lines. Its platformBuildVersionName='16' is Android 16, the platform behind compileSdk 36.
Look at the unzip -l list: it has no res/ folder (our only resource is a string, which lives in resources.arsc), a tiny classes.dex, and kotlin/*.kotlin_builtins files. Those come from the Kotlin standard library that AGP 9 adds to every app: R8 removed its classes but not these metadata files, which only Kotlin reflection reads. A Java-only app can exclude them:
android {
packaging { resources { excludes += "**/*.kotlin_builtins" } }
}apkanalyzer
apkanalyzer answers size questions and can compare two APKs, the core of a size-regression check:
mkdir -p hello/app/src/main/java/com/example/hello && cd hello
cat > settings.gradle.kts <<'KTS'
pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
rootProject.name = "hello"
include(":app")
KTS
echo 'plugins { id("com.android.application") version "9.4.1" apply false }' > build.gradle.kts
cat > app/src/main/AndroidManifest.xml <<'XML'
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="Hello">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
XML
cat > app/src/main/java/com/example/hello/MainActivity.java <<'JAVA'
package com.example.hello;
public class MainActivity extends android.app.Activity {
@Override protected void onCreate(android.os.Bundle state) {
super.onCreate(state);
android.widget.TextView view = new android.widget.TextView(this);
view.setText("Hello");
setContentView(view);
}
}
JAVA
cat > app/build.gradle.kts <<'KTS'
plugins { id("com.android.application") }
android {
namespace = "com.example.hello"
compileSdk = 36
defaultConfig { applicationId = "com.example.hello"; minSdk = 24; targetSdk = 36; versionCode = 21; versionName = "2.1.0" }
buildTypes { release { isMinifyEnabled = true; proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) } }
}
KTS
gradle wrapper > /dev/null
./gradlew -q assembleRelease
cp app/build/outputs/apk/release/app-release-unsigned.apk before.apk
sed -i 's/^android {/android {\n packaging { resources { excludes += "**\/*.kotlin_builtins" } }/' app/build.gradle.kts
./gradlew -q assembleRelease
cp app/build/outputs/apk/release/app-release-unsigned.apk after.apk
echo "=== summary (applicationId, versionCode, versionName)"
apkanalyzer apk summary after.apk
echo "=== raw file size: before / after"
apkanalyzer apk file-size before.apk
apkanalyzer apk file-size after.apk
echo "=== compare (old size, new size, difference, path), biggest changes"
apkanalyzer apk compare --different-only before.apk after.apk | sort -t