[General Questions and Answers] dennis96411:
Unable to install APKs through Package Installer ("App not installed"; error -20)

This problem always comes back to me, even after fresh installs, and I don't know why. I'm running Lollipop and every time I try to install an app using Package Installer, I get "App not installed". I see the following in a logcat I've captured:

02-16 16:07:50.227 W/ResourceType(1352): No package identifier when getting value for resource number 0x00000000
02-16 16:07:50.227 W/PackageManager(1352): Failure retrieving resources for com.nolanlawson.logcat: Resource ID #0x0
02-16 16:07:53.604 W/InstallAppProgress(9939): Replacing package:com.keramidas.TitaniumBackup
02-16 16:07:53.608 W/PackageManager(896): PackageManager.INSTALL_EXTERNAL
02-16 16:07:53.812 I/art (896): Explicit concurrent mark sweep GC freed 63746(3MB) AllocSpace objects, 19(3MB) LOS objects, 33% free, 30MB/45MB, paused 1.027ms total 116.619ms
[B]02-16 16:07:53.817 D/InstallAppProgress(9939): Installation error code: -20[/B]
02-16 16:07:53.984 I/art (9939): Explicit concurrent mark sweep GC freed 20661(1219KB) AllocSpace objects, 12(381KB) LOS objects, 40% free, 9MB/16MB, paused 698us total 13.539ms
02-16 16:07:54.008 I/art (9939): Explicit concurrent mark sweep GC freed 2248(153KB) AllocSpace objects, 1(38KB) LOS objects, 39% free, 9MB/16MB, paused 429us total 10.237ms
02-16 16:07:54.017 I/art (9939): Explicit concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 39% free, 9MB/16MB, paused 396us total 9.437ms
02-16 16:07:54.639 I/InstallAppProgress(9939): Finished installing com.keramidas.TitaniumBackup

After looking around for awhile, the error is logged by THIS:

private int getExplanationFromErrorCode(int errCode) {
Log.d(TAG, "Installation error code: " + errCode);
switch (errCode) {
case PackageManager.INSTALL_FAILED_INVALID_APK:
return R.string.install_failed_invalid_apk;
case PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES:
return R.string.install_failed_inconsistent_certificates;
case PackageManager.INSTALL_FAILED_OLDER_SDK:
return R.string.install_failed_older_sdk;
case PackageManager.INSTALL_FAILED_CPU_ABI_INCOMPATIBLE:
return R.string.install_failed_cpu_abi_incompatible;
default:
return -1;
}
}

Searching up error codes, I get THIS:

/**
* Installation return code: this is passed to the {@link IPackageInstallObserver} by
* {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
* the new package couldn't be installed in the specified install
* location because the media is not available.
* @hide
*/
@SystemApi
public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = [B]-20[/B];

Please, someone help me. I have no idea what these mean.

==========FIXED!==========

After a bit of researching, I came across THIS:

Could it be? Has my app install location been set to the external storage, which doesn't exist on the OnePlus One? I checked using the following command in Terminal Emulator on my phone, and lo-and-behold, there it is!

u0_a89@android:/ $ pm get-install-location
[B]2[external][/B]

I then applied the fix using the following commands:

su
pm set-install-location 1

This has ultimately fixed the problem that has been plaguing me every ROM installation! Let this be here for those who run into this problem in the future!