Can I remove this permission? (It cause INSTALL_FA

2019-02-15 13:10发布

问题:

My tester said that he couldn't install the app from Play Store to his Nexus 5 (Lollipop). He said he got this error

Unknown error code during application install “-505”

I took his phone and try to install the app via adb, I got this error

Failure [INSTALL_FAILED_DUPLICATE_PERMISSION 
        perm=com.example.gcm.permission.C2D_MESSAGE 
        pkg=com.mailchimp.alterego]

After some reading, I came across this writing from @Commonsware

http://commonsware.com/blog/2014/08/04/custom-permission-vulnerability-l-developer-preview.html

It's clearly that both my app and Mailchimp app (which installed on my tester's phone) has duplicated permission, com.example.gcm.permission.C2D_MESSAGE. I then check my git log to see when did I add that line to my AndroidManifest and found that it was when I implement GCM. Back then, I followed this tutorial

https://developer.android.com/google/gcm/client.html

I guess, both I and Mailchimp developer follow the same tutorial, added same permission and now both our app has duplicate permission.

So, I remove that permission from my AndroidManifest and now I'm able to install my app on my tester's phone. I test the GCM message by sending to package to GCM server from my php script and app still got GCM message as it was.

So, will there be other issue raised because of that missing permission and what is the point of having that permission anyway? (since without it, my app still got GCM message)

My concern is, if our app is using a plugin/library that required permission. We won't be able to install our app on Lollipop device if there is another installed app which using the same library, isn't it?

-- NOTE --

I already read this question, few people suggest the same thing to what I did, remove permission. But no one talking about what will happen after we do it or why do we have to add it.

INSTALL_FAILED_DUPLICATE_PERMISSION... C2D_MESSAGE

-- EDIT 1 --

I went back to the tutorial, the tutorial was right, it was my wrong implementation

I (and Mailchimp developer) should add permission with the name of our app package + ".permission.C2D_MESSAGE" instead of just copy and paste com.example.gcm.permission.C2D_MESSAGE

<permission android:name="com.mycompany.myappname.permission.C2D_MESSAGE" 
            android:protectionLevel="signature" />

But, this raise another question to me, tutorial said that if we don't add this permission or the name doesn't match the pattern, app won't get the message.But I got the message when I test even when I remove this pemission... weird.

回答1:

As described in INSTALL_FAILED_DUPLICATE_PERMISSION... C2D_MESSAGE , you should use ${applicationId} instead a static application id in the AndroidManifest.

Example:

<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>

It will fix your problem and if you starting using Flavor everything will work perfectly too. ;)



回答2:

Change your package name to some other package name, instead of deleting that permissions.

package="com.example.gcm" 

to

package="com.appname"  //use any name here like your app name or company name


回答3:

Android 5.0. You have Multi-User, so You must Uninstall for all Users Following steps:

After Uninstalling App. You may found that Your app name in Apps List of Downloaded Tab.

Go to Settings->Apps. At bottom of list you found YourApp with "NOT INSTALLED" Tag -> Open -> Click on Option Menu and Select "Uninstall for all Users".

After that process you successfully install new app and running well.