安装提示错误 [INSTALL_FAILED_OLDER_SDK]的解决方案

时间:2025-01-31 09:06:17
Install APK with adb: 
$ platform-tools/adb install out/target/product/generic/system/app/ 
233 KB/s (12588 bytes in 0.052s) 
pkg: /data/local/tmp/ 
Failure [INSTALL_FAILED_OLDER_SDK] 
Error message in logcat: 
D/PackageParser(   60): Scanning package: /data/app/ 
W/PackageParser(   60): /data/app/ (at Binary XML file line #0): Requires development platform AOSP but this is a release platform. 
The error was created by , which compares the android:minSdkVersion and android:targetSdkVersion attributes of the uses-sdk element of in the APK file against the SDK version of the device or emulator. The SDK version on the device has to be greater than that required by android:minSdkVersion. 

In my case, since I built the package with AOSP, the target emulator has to be AOSP also. This is the relavant section in : 
<uses-sdk android:minSdkVersion="AOSP" 
        android:targetSdkVersion="AOSP"> 
</uses-sdk> 



And the relevant section in : 
if (minCode != null) { 
    if (!(SDK_CODENAME)) { 
if (SDK_CODENAME != null) { 
    outError[0] = "Requires development platform " + minCode 
    + " (current platform is " + SDK_CODENAME + ")"; 
} else { 
    outError[0] = "Requires development platform " + minCode 
    + " but this is a release platform."; 

mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK; 
return null; 
    } 
} else if (minVers > SDK_VERSION) { 
    outError[0] = "Requires newer sdk version #" + minVers 
    + " (current version is #" + SDK_VERSION + ")"; 
    mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK; 
    return null; 

                    
if (targetCode != null) { 
    if (!(SDK_CODENAME)) { 
if (SDK_CODENAME != null) { 
    outError[0] = "Requires development platform " + targetCode 
    + " (current platform is " + SDK_CODENAME + ")"; 
} else { 
    outError[0] = "Requires development platform " + targetCode 
    + " but this is a release platform."; 

mParseError = PackageManager.INSTALL_FAILED_OLDER_SDK; 
return null; 
    } 
    // If the code matches, it definitely targets this SDK. 
     
    = .VERSION_CODES.CUR_DEVELOPMENT; 
} else { 
    = targetVers; 
}