I have a ZTE phone I'm unable to reinstall facebook on using the Google Play Store - I get the notorious -505 unknown error.
If I install a downloaded facebook apk using adb I get the following error.
pkg: /data/local/tmp/com.facebook.katana.apk Failure [INSTALL_FAILED_DUPLICATE_PERMISSION
perm=com.facebook.katana.permission.RECEIVE_ADM_MESSAGE pkg=com.facebook.katana]
No facebook packages are installed according to the output of
pm list packages
So the problem appears to be caused by stray permissions that have been left behind and are prevent facebook from reinstalling.
Listing the facebook permissions over adb I get the following
adb shell pm list permissions | grep facebook
permission:com.facebook.katana.permission.CROSS_PROCESS_BROADCAST_MANAGER
permission:com.facebook.permission.prod.FB_APP_COMMUNICATION
permission:com.facebook.receiver.permission.ACCESS
permission:com.facebook.katana.permission.RECEIVE_ADM_MESSAGE
permission:com.facebook.katana.provider.ACCESS
permission:com.facebook.katana.permission.C2D_MESSAGE
permission:com.facebook.permission.debug.SYSTEM_COMMUNICATION
Uninstalling using adb doesn't get rid of these permissions adb uninstall or adb uninstall -k com.facebook.katana
I don't see the partial facebook 'not installed' entry in settings/apps/downloaded that some users report. My apparently customised settings app doesn't allow access to multi-user features which some people find is related to similar problems.
Can I clean up these permissions with adb? pm revoke won't do it perhaps due to Lollipop limitations. I don't currently have root access and I'm reluctant to root the phone.
adb shell pm revoke com.facebook.katana com.facebook.katana.permission.RECEIVE_ADM_MESSAGE
Operation not allowed: java.lang.SecurityException: Permission com.facebook.katana.permission.RECEIVE_ADM_MESSAGE is not
a changeable permission type
ADDITIONAL DIAGNOSTIC STEPS:
To eliminate the possibility of an invalid APK I used the Google Play Store app to install the facebook app and at the same time monitored the system using logcat on its most verbose settings. Searching for facebook in the log finds the following error messages which are very similar to the errors from installing the APK directly above:
[ 10-26 01:14:26.615 662: 1360 V/ActivityManager ]
Broadcast: Intent { act=com.android.launcher.action.ACTION_PACKAGE_INSTALLING dat=package:com.facebook.katana flg=0x10 pkg=com.google.android.googlequicksearchbox } ordered=false userid=0 callerApp=ProcessRecord{142b6192 2619:com.android.vending/u0a14}
[ 10-26 01:14:43.492 662: 704 W/PackageManager ]
Package com.facebook.katana attempting to redeclare permission com.facebook.katana.permission.RECEIVE_ADM_MESSAGE already owned by com.facebook.katana
[ 10-26 01:14:43.975 2619: 2619 E/Finsky ]
[1] 2.onReceive: Error -505 while installing com.facebook.katana: INSTALL_FAILED_DUPLICATE_PERMISSION: Package com.facebook.katana attempting to redeclare permission com.facebook.katana.permission.RECEIVE_ADM_MESSAGE already owned by com.facebook.katana
[ 10-26 01:14:43.975 2619: 2619 W/Finsky ]
[1] 3.installFailed: Install failure of com.facebook.katana: -505 null
"permission com.facebook.katana.permission.RECEIVE_ADM_MESSAGE already owned by com.facebook.katana".
Does this mean I have some sort of remnant APK from a previous com.facebook.katana installation (facebook was previously installed then uninstalled)? Or does this mean the permissions on the device still contain some reference to a non-existent app com.facebook.katana? Any further steps I can take to diagnose this problem?
EDIT - Blocking apk appears to be partially uninstalled system bloatware facebook app
If attempt to list uninstalled third-party packages, their apk files and installers using adb:
adb shell pm list packages -f -i -u -3
I can see an entry for facebook
package:/system/vendor/operator/app/facebook/facebook.apk=com.facebook.katana installer=null
The only other third party entries in system appear to have been pre-installed bloatware on the phone. twitterappforzte is a good example...
package:/system/vendor/operator/app/CleanMaster/CleanMaster.apk=com.cleanmaster.mguard installer=null
package:/system/vendor/operator/app/twitterappforzte/twitterappforzte.apk=com.twitter.android installer=null
Using ADB it's apparent there is an apk file still present here which is presumably blocking the new installation:
shell@P182A20:/system/vendor/operator/app/facebook $ ls -l
drwxr-xr-x root shell 2015-03-20 09:30 arm
-rw-r--r-- root root 26450949 2015-03-20 09:30 facebook.apk
facebook is not listed if I filter uninstalled apps by only listing disabled apps.
I've tried pulling this bloatware facebook.apk file from the phone to my local disk and reinstalling using adb but I get installation failures.
C:\Program Files (x86)\Minimal ADB and Fastboot>adb install facebook.apk
5155 KB/s (26450949 bytes in 5.010s)
pkg: /data/local/tmp/facebook.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
Trying to disable/enable the remnant package using ADB fails with security error, presumably because it's a system app.
C:\Program Files (x86)\Minimal ADB and Fastboot>adb shell pm disable com.facebook.katana
Error: java.lang.SecurityException: Permission Denial: attempt to change component state from pid=16143, uid=2000, package uid=10098
Huge demerits for lousy engineering to ZTE here. Pre-installing facebook and twitter apk files with unknown provenance that can't be updated and prevent updated play store versions from being installed. Great way to put security holes on their phones.
Is there any way to reinstall this system bloatware apk file which is very much still present? If not is it possible to flag this partially 'uninstalled' app as disabled so that it won't interfere with new installations?
.apk
from a trusted source? The error message suggests a "wrongManifest
" (with a permission declared twice) – rather an indicator of a "tainted.apk
" (someone tampered with it – of the original dev got it wrong; I doubt the latter with a popular app like this, or we had heard of it pretty loud already).