Android: How to find which platform version an APK targets?

Given an APK, is it possible to determine which version of Android platform it targets?


Solution 1:

Use aapt:

aapt list -a package.apk | grep SdkVersion

You will see version numbers in hex. e.g.:

  A: android:minSdkVersion(0x0101020c)=(type 0x10)0x3
  A: android:targetSdkVersion(0x01010270)=(type 0x10)0xc

For this apk, minSdkVersion is 0x3 i.e. 3, and targetSdkVersion is 0xc i.e. 12.

Solution 2:

Use apktool

java -jar apktool.jar d app.apk

Then look in the generated apktool.yml file for this:

sdkInfo:
  minSdkVersion: '11'
  targetSdkVersion: '17'

You can match the SDK version to Android version here. In the above example minimum Android version is 3.0 and target version is 4.2.

Solution 3:

simply use aapt dump badging my_apk_file.apk to get a lot of info about your apk. grep filter by Version aapt dump badging my_apk_file.apk|grep Version

Output with $ANDROID_SDK_ROOT/build-tools/30.0.3/aapt:

package: name=... versionCode=... versionName=... compileSdkVersion='29' compileSdkVersionCodename='10'
sdkVersion:'11'
targetSdkVersion:'29'

The apk for any installed app $app (eg com.google.android.apps.docs) can be retrieved from your device with:

adb pull $(adb shell dumpsys package $app | grep path: | cut -c11-) $app.apk