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

  • Post author:
  • Post category:其他


原先在1.6rc1上写的程序,拿到1.5的SDK重新编译后却不能用

abd install bin/xxx.apk

安装上去,提示错误是:

Failure [INSTALL_FAILED_OLDER_SDK]

找了一下,是这个原因:

打开源码目录下的AndroidManifest.xml文件,然后注释掉或者删除掉这行:

<uses-sdk android:minSdkVersion=”4″ />

另一篇文章:

通过在manifest中添加

android

.uid.system和在Android.mk中添加LOCAL_CERTIFICATE := platform,然后MMM

编译



获取

次特权。但是我通过MMM编译出来的APK不能在

系统

提供的SDK中创建的AVD里安装,提示Failure [INSTALL_FAILED_OLDER_SDK]

解决方法:

/build/core/version_defaults.mk文件中这一段

ifeq “” “$(DEFAULT_APP_TARGET_SDK)”

# This is the default minSdkVersion and targetSdkVersion to use for

# all .apks created by the build system.  It can be overridden by explicitly

# setting these in the .apk’s AndroidManifest.xml.  It is either the code

# name of the development build or, if this is a release build, the official

# SDK version of this release.

ifeq “REL” “$(PLATFORM_VERSION_CODENAME)”

DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION)

else

DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)

endif

endif

将DEFAULT_APP_TARGET_SDK直接赋值相应的API等级即可。

另一篇文章:


Install APK with adb:




$ platform-tools/adb install out/target/product/generic/system/app/Bundled.apk




233 KB/s (12588 bytes in 0.052s)




pkg: /data/local/tmp/Bundled.apk




Failure [INSTALL_FAILED_OLDER_SDK]




Error message in logcat:




D/PackageParser(   60): Scanning package: /data/app/vmdl64930.tmp




W/PackageParser(   60): /data/app/vmdl64930.tmp (at Binary XML file line #0): Requires development platform AOSP but this is a release platform.




The error was created by android.content.pm.PackageParser, which compares the android:minSdkVersion and android:targetSdkVersion attributes of the uses-sdk element of AndroidManifest.xml 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 AndroidManifest.xml:




<uses-sdk android:minSdkVersion=”AOSP”




android:targetSdkVersion=”AOSP”>




</uses-sdk>










And the relevant section in android.content.pm.PackageParser:




if (minCode != null) {




if (!minCode.equals(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 (!targetCode.equals(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.




pkg.applicationInfo.targetSdkVersion




= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT;




} else {




pkg.applicationInfo.targetSdkVersion = targetVers;




}






结论:只有apk无源代码,无解。