Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know which Android API an APK was built against

Tags:

android

build

When an APK is generated with a given API Level, is there a way to know which API level was used for compiling just having the APK file?

The minSdkVersion does not necessarily match the API Level used for compiling the project, it is just a note for the Android installer to block the app if minSdkVersion > current version

like image 470
OlivierM Avatar asked May 19 '15 22:05

OlivierM


People also ask

Can you see source code of APK file?

In Android studio 2.3, Build -> Analyze APK -> Select the apk that you want to decompile . You will see it's source code.

How do I analyze an APK file?

Drag an APK or app bundle into the Editor window of Android Studio. Switch to the Project perspective in the Project window and then double-click the APK in the default build/output/apks/ directory. Select Build > Analyze APK in the menu bar and then select your APK or app bundle.

How do I know my Android API version?

Tap the "Software Information" option on the About Phone menu. The first entry on the page that loads will be your current Android software version.

What is API 19 in Android?

Android api level 19 means the android os version (kitkat). It contains the standard android packages(from Android Open Source Projects). But the google api 19 is the android api 19+ google api's like google settings and other packages provided by google.


1 Answers

This is another way to get the targetSdkVersion and the versionCode of my application:

try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            int versionCode = packageInfo.versionCode;
            int targetSdkVersion = packageInfo.applicationInfo.targetSdkVersion;

        }
        catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, e.getMessage());
        }

using Android Studio, the values are defined into my build.gradle file

   defaultConfig {
        applicationId "com.tuna.hello.androidstudioapplication"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 12
        versionName "1.0"
    }
like image 151
Jorgesys Avatar answered Oct 12 '22 01:10

Jorgesys