I am using Google notifications in my app, and until now I have done below in the manifest:
<!-- GCM -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- This app has permission to register and receive data message. -->
<!-- Creates a custom permission so only this app can receive its messages. NOTE: APP_PACKAGE.permission.C2D_MESSAGE -->
<permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE" />
<!-- END GCM -->
It worked perfectly until I updated my Nexus 7 to Android 5.0.
Now when I try to install the app in this device with Eclipse, I get this error:
INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.myapp.permission.C2D_MESSAGE pkg=com.myapp
I don't understand what is wrong... it was working perfectly until Android 5.0.
I know that I am using C2D_MESSAGE
in two lines, permission
and uses-permission
but I have copied that code from the original Google GCM guide, so it must be fine.
I had the same problem with a custom signature permission on Android-21 and solved it by making sure I was doing a complete uninstall.
This is an edge case that occurs when:
Command line example
Here is a command-line transcript that demonstrates the issue and how to solve it. At this point a debug version is installed and I am trying to install a production version signed with the release key:
Eclipse example
Going in the opposite direction (trying to install a debug build from Eclipse when a release build is already installed), I get the following dialog:
If you just answer yes at this point the install will succeed.
Device example
As pointed out in another answer, you can also go to an app info page in the device settings, click the overflow menu, and select "Uninstall for all users" to prevent this error.
Previously it used to say that an app with different signature is found on device. When installing from IDE it would also ask do you want to uninstall it?
But I think from Android 5.0 they have changed the reason for uninstallation. It does not happen if you are installing app with the same signature
replace below lines:
Remove
Run App... Then Add the permisson again and Run App.
Ready!.
While giving this error it will clearly mention the package name of the app because of which the permission was denied. And just uninstalling the application will not solve the problem. In order to solve problem we need to do the following step:
Problem solved :D
In my case I was using a third party library (i.e. vendor) and the library comes with a sample app which I already had install on my device. So that sample app was now conflicting each time I try to install my own app implementing the library. So I just uninstalled the vendor's sample app and it works afterwards.