AI智能
改变未来

android adb install 失败的错误分析 PartII

android 源码中, 关于install apk failed 的错误定义

/**0320      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0321      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.0322      * @hide0323      */0324     public static final int INSTALL_SUCCEEDED = 1;03250326     /**0327      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0328      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is0329      * already installed.0330      * @hide0331      */0332     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;03330334     /**0335      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0336      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive0337      * file is invalid.0338      * @hide0339      */0340     public static final int INSTALL_FAILED_INVALID_APK = -2;03410342     /**0343      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0344      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in0345      * is invalid.0346      * @hide0347      */0348     public static final int INSTALL_FAILED_INVALID_URI = -3;03490350     /**0351      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0352      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager0353      * service found that the device didn\'t have enough storage space to install the app.0354      * @hide0355      */0356     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;03570358     /**0359      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0360      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a0361      * package is already installed with the same name.0362      * @hide0363      */0364     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;03650366     /**0367      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0368      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0369      * the requested shared user does not exist.0370      * @hide0371      */0372     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;03730374     /**0375      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0376      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0377      * a previously installed package of the same name has a different signature0378      * than the new package (and the old package\'s data was not removed).0379      * @hide0380      */0381     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;03820383     /**0384      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0385      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0386      * the new package is requested a shared user which is already installed on the0387      * device and does not have matching signature.0388      * @hide0389      */0390     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;03910392     /**0393      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0394      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0395      * the new package uses a shared library that is not available.0396      * @hide0397      */0398     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;03990400     /**0401      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0402      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0403      * the new package uses a shared library that is not available.0404      * @hide0405      */0406     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;04070408     /**0409      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0410      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0411      * the new package failed while optimizing and validating its dex files,0412      * either because there was not enough storage or the validation failed.0413      * @hide0414      */0415     public static final int INSTALL_FAILED_DEXOPT = -11;04160417     /**0418      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0419      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0420      * the new package failed because the current SDK version is older than0421      * that required by the package.0422      * @hide0423      */0424     public static final int INSTALL_FAILED_OLDER_SDK = -12;04250426     /**0427      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0428      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0429      * the new package failed because it contains a content provider with the0430      * same authority as a provider already installed in the system.0431      * @hide0432      */0433     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;04340435     /**0436      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0437      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0438      * the new package failed because the current SDK version is newer than0439      * that required by the package.0440      * @hide0441      */0442     public static final int INSTALL_FAILED_NEWER_SDK = -14;04430444     /**0445      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0446      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0447      * the new package failed because it has specified that it is a test-only0448      * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}0449      * flag.0450      * @hide0451      */0452     public static final int INSTALL_FAILED_TEST_ONLY = -15;04530454     /**0455      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0456      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0457      * the package being installed contains native code, but none that is0458      * compatible with the the device\'s CPU_ABI.0459      * @hide0460      */0461     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;04620463     /**0464      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0465      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0466      * the new package uses a feature that is not available.0467      * @hide0468      */0469     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;04700471     // ------ Errors related to sdcard0472     /**0473      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0474      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0475      * a secure container mount point couldn\'t be accessed on external media.0476      * @hide0477      */0478     public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;04790480     /**0481      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0482      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0483      * the new package couldn\'t be installed in the specified install0484      * location.0485      * @hide0486      */0487     public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;04880489     /**0490      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0491      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0492      * the new package couldn\'t be installed in the specified install0493      * location because the media is not available.0494      * @hide0495      */0496     public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;04970498     /**0499      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0500      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0501      * the new package couldn\'t be installed because the verification timed out.0502      * @hide0503      */0504     public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;05050506     /**0507      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0508      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0509      * the new package couldn\'t be installed because the verification did not succeed.0510      * @hide0511      */0512     public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;05130514     /**0515      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0516      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0517      * the package changed from what the calling program expected.0518      * @hide0519      */0520     public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;05210522     /**0523      * Installation return code: this is passed to the {@link IPackageInstallObserver} by0524      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if0525      * the new package is assigned a different UID than it previously held.0526      * @hide0527      */0528     public static final int INSTALL_FAILED_UID_CHANGED = -24;
/**0614      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by0615      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}0616      * if the system failed to install the package because of system issues.0617      * @hide0618      */0619     public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;

you can find the source code here

http://osxr.org/android/source/frameworks/base/core/java/android/content/pm/PackageManager.java

对于这些错误, 后续会根据遇到的情况及对应的处理措施,持续更新。

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » android adb install 失败的错误分析 PartII