简体   繁体   中英

How does Android system find sdk info in app that installed on the phone?

I want to know which target the apk is aiming, I use apktool to decompile the apk file, but I can't find the sdk info in the decompiled apk files, but only in the apktool.yml file like this:

sdkInfo:  
  minSdkVersion: '14'  
  targetSdkVersion: '23' 

I wonder where can Android system find the information in the apk that installed in the phone? Why I can't find the information in the decompiled files?


update:

There are suspicious information in decompiled AndroidManifest.xml file, but there are consistent with the information in the apktool.yml file.

Thanks in advance.

AndroidManifest.xml files containts those values:

minSdkVersion targetSdkVersion

https://ibotpeaches.github.io/Apktool/

Use apktool to decode your APK-file.

The following command will print out the xmltree of the android manifest inside an apk file:

aapt dump xmltree file.apk AndroidManifest.xml

Sample output:

N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=17)
    A: android:versionCode(0x0101021b)=(type 0x10)0x7
    A: android:versionName(0x0101021c)="2.1-update1" (Raw: "2.1-update1")
    A: package="com.android.spare_parts" (Raw: "com.android.spare_parts")
    E: uses-sdk (line=0)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0x7
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0x7
    E: uses-permission (line=19)
      A: android:name(0x01010003)="android.permission.SET_ANIMATION_SCALE" (Raw: "android.permission.SET_ANIMATION_SCALE")
    E: uses-permission (line=20)
      A: android:name(0x01010003)="android.permission.CHANGE_CONFIGURATION" (Raw: "android.permission.CHANGE_CONFIGURATION")
    E: uses-permission (line=21)
      A: android:name(0x01010003)="android.permission.WRITE_SETTINGS" (Raw: "android.permission.WRITE_SETTINGS")
    E: application (line=23)
      A: android:label(0x01010001)=@0x7f060000
      A: android:icon(0x01010002)=@0x7f020000
      E: activity (line=26)
        A: android:name(0x01010003)="SpareParts" (Raw: "SpareParts")
        E: intent-filter (line=27)
          E: action (line=28)
            A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
          E: category (line=29)
            A: android:name(0x01010003)="android.intent.category.DEFAULT" (Raw: "android.intent.category.DEFAULT")
          E: category (line=30)
            A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")

Here, you can see on lines 7 and 8 the minSdkVersion and targetSdkVersion. Source

You can find it in your app / main module level build.gradle file.

In below section

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'
    defaultConfig {
        applicationId "yourApplicationPackage"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
}

minSdkVersion 14

targetSdkVersion 23

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM