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

Android

Android Problem Overview


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

Android Solutions


Solution 1 - Android

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 - Android

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 - Android

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

Solution 4 - Android

You can use apkanalyzer, it is is included in the Android SDK Tools, more infos here https://developer.android.com/studio/command-line/apkanalyzer

Prints the minimum SDK version.

apkanalyzer -h manifest min-sdk myapk.apk

Prints the target SDK version

apkanalyzer -h manifest target-sdk myapk.apk

Solution 5 - Android

You can extract the APK and look in the manifest file for the platform target.

Solution 6 - Android

like derek said above

use the apktool to decompile the apk and check the manifest version

platform versions can be found here

Solution 7 - Android

If you don't have grep, you can use

aapt list -a package.apk >file.txt

and search for minSdkVersion and targetSdkVersion in file.txt.

Solution 8 - Android

If you want to find these info from your mobile device you can install My APK app which gives you good information about apps You can get it at https://play.google.com/store/apps/details?id=com.andatsoft.myapk.fwa&hl=en

The app which you want to have these information about, must either installed on your mobile device or you must have the app apk on your mobile.

Solution 9 - Android

In my case, I opened the apk file on Android Studio. So I can check the version of android at AndroidManifest.xml.

Solution 10 - Android

if you want it programmatically try use PackageManager class:

public PackageManager getPackageArchiveInfo(String archiveFilePath, int flags)

then read ApplicationInfo field and targetSdkVersion in it;

Solution 11 - Android

You can run following command to just get the API level (integer):

aapt dump badging "your_apk.apk" | awk '/targetSdkVersion/{gsub("targetSdkVersion:''|''","");  print $1}'

The output you'll get will be as below, in case it was compiled against KitKat (API 19):

> 19

PS: aapt is located in folder <Android-Sdk>/build-tools/<build-tools-version>/.

Solution 12 - Android

The fastest way to get APK information is to use this online tool : https://www.sisik.eu/apk-tool

Solution 13 - Android

To find the platform targets for an APK file, use apktool. Follow these instructions:

  1. Use the GitHub repo to install it https://ibotpeaches.github.io/Apktool/.

  2. After installing then run the following command -> apktool d file.apk

  3. open the file folder.

  4. locate the file named apktool.yml

  5. the information is found in the SDK info: Image 1, Image 2

Solution 14 - Android

If you are using Nautilus, you can add a column provider and a property page provider for APK files. This will provide lots of informations, including SdkVersion.

Steps are explained on this link : http://bernaerts.dyndns.org/linux/76-gnome/324-gnome-nautilus-apk-column-property-provider-extension

Cheers.

Solution 15 - Android

You can use http://www.javadecompilers.com/apk to decomplier file apk and you can find it in Mandifest

Solution 16 - Android

Another bush util function:

function android-target-sdk-version {
    aapt list -a $1 | grep targetSdkVersion | grep -o '....$' | awk '{print $1+0}'
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionzer0stimulusView Question on Stackoverflow
Solution 1 - AndroidchiukiView Answer on Stackoverflow
Solution 2 - Androidmiles82View Answer on Stackoverflow
Solution 3 - AndroidThuptenView Answer on Stackoverflow
Solution 4 - AndroidTejpal SharmaView Answer on Stackoverflow
Solution 5 - AndroidRealCasuallyView Answer on Stackoverflow
Solution 6 - AndroidwowthatisrandomView Answer on Stackoverflow
Solution 7 - AndroidSylvainView Answer on Stackoverflow
Solution 8 - AndroidAlireza FattahiView Answer on Stackoverflow
Solution 9 - AndroidL.YunView Answer on Stackoverflow
Solution 10 - AndroidVladimirView Answer on Stackoverflow
Solution 11 - AndroidSufianView Answer on Stackoverflow
Solution 12 - AndroidJean-Daniel GasserView Answer on Stackoverflow
Solution 13 - AndroidCoding_A_NationView Answer on Stackoverflow
Solution 14 - Androidnicolas bernaertsView Answer on Stackoverflow
Solution 15 - AndroidThientvseView Answer on Stackoverflow
Solution 16 - AndroidelevenView Answer on Stackoverflow