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.
![]()
Pratik Butani
59.2k55 gold badges265 silver badges427 bronze badges
asked Nov 20, 2014 at 15:57
2
I’ve found a solution that works for me.
In My Device (Nexus 7) Android 5.0. Lollipop I follow these steps.
After Uninstalling App You will find App Name under Apps List of the Downloaded tab.
- Go to Settings
- Apps
- At the bottom of the list, you will find
YourAppwith a «NOT INSTALLED» Tag - Open
- Click on
OptionMenuand Select «Uninstall for all Users»
After these steps, I successfully install the new app and it’s running well.
answered Dec 13, 2014 at 6:52
![]()
Pratik ButaniPratik Butani
59.2k55 gold badges265 silver badges427 bronze badges
9
Remove
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
Run App…
Then Add the permisson again and Run App.
Ready!.
![]()
Pratik Butani
59.2k55 gold badges265 silver badges427 bronze badges
answered Jan 4, 2015 at 15:40
Delmirio SeguraDelmirio Segura
1,6531 gold badge9 silver badges5 bronze badges
7
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:
- An application defines a custom permission using signature level security
- You attempt to update the installed app with a version signed with a different key
- The test device is running Android 21 or newer with support for multiple users
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:
# This fails because the debug version defines the custom permission signed with a different key:
[root@localhost svn-android-apps]# . androidbuildscripts/my-adb-install Example release
920 KB/s (2211982 bytes in 2.347s)
pkg: /data/local/tmp/Example-release.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.android.example.PERMISSION_EXAMPLE_PLUGIN pkg=com.example.android.example]
# I use uninstall -k because apparently that is similar to uninstalling as a user
# by dragging the app out of the app tray:
[root@localhost svn-android-apps]# /android-sdk-linux/platform-tools/adb uninstall -k com.example.android.example
The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell pm uninstall -k com.example.android.example'
# Let's go ahead and do that:
[root@localhost svn-android-apps]# /android-sdk-linux/platform-tools/adb shell pm uninstall -k com.example.android.example
Success
# This fails again because the custom permission apparently is part of the data/cache
# that was not uninstalled:
[root@localhost svn-android-apps]# . androidbuildscripts/my-adb-install Example release
912 KB/s (2211982 bytes in 2.367s)
pkg: /data/local/tmp/Example-release.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.android.example.PERMISSION_EXAMPLE_PLUGIN pkg=com.example.android.example]
# In spite of the warning above, simply doing a full uninstall at this point turned out to
# work (for me):
[root@localhost svn-android-apps]# /android-sdk-linux/platform-tools/adb uninstall com.example.android.example
Success
# Release version now successfully installs:
[root@localhost svn-android-apps]# . androidbuildscripts/my-adb-install Example release
898 KB/s (2211982 bytes in 2.405s)
pkg: /data/local/tmp/Example-release.apk
Success
[root@localhost svn-android-apps]#
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.
answered Nov 23, 2014 at 15:48
3
I’ve solved this without having to resort to uninstalling the alternate apk first (what a pain, right?). To successfully install both a debug and release version of an apk, simply use gradle’s built-in ${applicationId} placeholder within the AndroidManifest.xml to modify the permissions’ android:name values at compile time.
The build.gradle file snippet:
buildTypes {
debug {
applicationIdSuffix ".debug"
...
}
}
The AndroidStudio.xml file snippet:
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
You can inspect the modified AndroidManifest.xml file within the apk using aapt l -a app-debug.apk to ensure the placeholder was properly applied. If you use various product flavors, I’m sure you can apply a variation of this method to suit your needs.
answered Dec 31, 2014 at 2:44
![]()
JackpileJackpile
1,0758 silver badges18 bronze badges
5
Remove any «Hard Coded» reference of your package name, from your manifest file.
(This is best practice even if you don’t using productFlavors)
For example, if your manifest contains:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="com.yourpackage.name.permission.C2D_MESSAGE"/>
<permission
android:name="com.yourpackage.name.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<permission
android:name="com.yourpackage.name.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
Changed it to:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<permission
android:name="${applicationId}.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
Then, in your module gradle file, set your relevant applicationId:
signingConfigs {
stage {
storeFile file('keystore/stage.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
production {
storeFile file('keystore/playstore.keystore')
storePassword store_password
keyAlias key_alias
keyPassword key_password
}
}
productFlavors {
staging {
signingConfig signingConfigs.staging
applicationId defaultConfig.applicationId + ".staging"
versionName defaultConfig.versionName + "-staging"
}
production {
signingConfig signingConfigs.production
}
}
You can follow this tutorial for more info
answered May 2, 2016 at 22:59
DavidDavid
36.7k32 gold badges120 silver badges140 bronze badges
2
try to uninstall the app with adb:
adb uninstall com.yourpackage
answered Nov 26, 2014 at 20:37
![]()
GiuseppeGiuseppe
2,0851 gold badge21 silver badges26 bronze badges
3
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:
- Go to settings
- Go to app
- Go to downloaded app list
- You can see the uninstalled application in the list
- Click on the application, go to more option
- Click on uninstall for all users options
Problem solved 😀
answered Nov 24, 2014 at 13:21
![]()
Preethi RaoPreethi Rao
5,0671 gold badge15 silver badges29 bronze badges
0
Installing an application in OS 5.0 i get this message:
INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.myapp.permission.C2D_MESSAGE pkg=com.myapp
There´s no duplicated packages, and we can solve this issue uninstalling manually the old application or using the adb:
adb uninstall com.yourpackage
answered Jan 27, 2015 at 17:18
![]()
JorgesysJorgesys
122k23 gold badges328 silver badges264 bronze badges
None of the above worked for me. My app was working fine in previous than Lollipop. But when I tested it on Lollipop the above error came up. It refused to install. I didn’t have any previous versions installed so all the above solutions are invalid in my case. But thanks to this SO solution now it is running fine. Just like most developers I followed Google’s misleading tutorial and I added the permissions by copy and paste like this:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.google.android.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
This would work with older versions < Lollipop. So now I changed to:
<uses-permission android:name="com.mycompany.myappname.c2dm.permission.RECEIVE" />
<permission android:name="com.mycompany.myappname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
answered Jan 4, 2016 at 0:52
![]()
The_MartianThe_Martian
3,5963 gold badges30 silver badges60 bronze badges
CommonsWare is right, but in my opinion this is a (bug)poor way to say: «The apk installed on the device is signed with a different certificate then the new one you are trying to install».
This is probably a new bug since in the past it used to ask whether or not to uninstall the app from the device due to wrong certificate.
The solution as painful as it may be would be to uninstall the app it manually.
Also what we’ve done for the sake of team development, we added the debug keystore to our repository, and point gradle to use it like so:
android {
...
signingConfigs {
debug {
storeFile file("../certificates/debug.keystore")
}
}
...
buildTypes {
debug {
signingConfig signingConfigs.debug
}
}
...
}
And now when passing devices between team members, we all use the same debug certificate, so there is no issue. 🙂
answered Nov 30, 2014 at 9:25
TacB0sSTacB0sS
10k12 gold badges72 silver badges117 bronze badges
In Android 5, check your settings -> apps. Instead of deleting for just the active user (since android 5 can have multiple users and my phone had a guest user) tap on the accessory button in the top right corner of the action/toolbar and choose «uninstall for all users». It appears that in Android 5 when you just uninstall from launcher you only uninstall the app for the active user.
The app is still on the device.. This had me dazzled to since I was trying to install a release version, didn’t work so I thought ow right must be because I still have the debug version installed, uninstalled the app. But than still couldn’t install.. First clue was a record in the app list of the uninstalled app with the message next to it that it was uninstalled (image).


answered Dec 28, 2014 at 11:20
JordyJordy
1,7341 gold badge22 silver badges32 bronze badges
1
See this link it said that it will work when they are signed by the same key. The release key and the debug key are not the same.
So do it:
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release//signing by the same key
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt'
}
debug {
applicationIdSuffix ".debug"
debuggable true
signingConfig signingConfigs.release//signing by the same key
}
}
signingConfigs {
release {
storeFile file("***\key_.jks")
storePassword "key_***"
keyAlias "key_***"
keyPassword "key_"***"
}
}
answered Oct 20, 2015 at 15:27
![]()
NickUnuchekNickUnuchek
10.8k10 gold badges94 silver badges133 bronze badges
replace below lines:
<permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
answered Sep 9, 2016 at 4:49
Sỹ PhạmSỹ Phạm
5316 silver badges14 bronze badges
In my case, I had several applications installed having the same domain name in the package name as follows.
com.mypackage.app1
com.mypackage.app2
com.mypackage.app3
...
I had to uninstall all the apps having similar package names and reinstall them again in order to get rid of the problem.
To find all package names from the device I used the following.
adb shell pm list packages
Then I grabbed the packages that match my package name that I am looking for.
dumpsys | grep -A18 "Package [com.mypackage]"
Then uninstalled all the apps having that domain.
uninstall com.mypackage.app1
uninstall com.mypackage.app2
uninstall com.mypackage.app3
...
You can also uninstall the applications using the Settings app. Go to the Settings -> Apps -> Find the app -> Uninstall
Hope that helps someone having the same problem as me.
answered Feb 18, 2020 at 21:18
![]()
Reaz MurshedReaz Murshed
23.1k13 gold badges78 silver badges96 bronze badges
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
answered Nov 25, 2014 at 2:22
YasirYasir
4531 gold badge6 silver badges15 bronze badges
I encountered the same problem with a nexus 5 Android Lollipop 5.0.1:
Installation error: INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.android.** pkg=com.android.**
And in my case I couldn’t fix this problem uninstalling the app because it was an android app, but I had to change my app custom permissions name in manifest because they were the same as an android app, which I could not uninstall or do any change.
Hope this helps somebody!
answered Dec 23, 2014 at 13:47
![]()
Ultimo_mUltimo_m
4,6083 gold badges39 silver badges60 bronze badges
In my case I received following error
Installation error: INSTALL_FAILED_DUPLICATE_PERMISSION
perm=com.map.permission.MAPS_RECEIVE pkg=com.abc.Firstapp
When I was trying to install the app which have package name com.abc.Secondapp. Here point was that app with package name com.abc.Firstapp was already installed in my application.
I resolved this error by uninstalling the application with package name com.abc.Firstapp and then installing the application with package name com.abc.Secondapp
I hope this will help someone while testing.
answered Oct 6, 2015 at 11:03
![]()
In your AndroidManifest.xml file, change your specially declared permissions’ names, for example:
<!-- 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 -->
to this,
<!-- Creates a custom permission so only this app can receive its messages. NOTE: APP_PACKAGE.permission.C2D_MESSAGE -->
<permission android:name="com.myapprocks.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapprocks.permission.C2D_MESSAGE" />
<!-- END GCM -->
com.myapprocks this part solves the conflict with your other app.
answered Apr 16, 2016 at 9:04
resw67resw67
1392 silver badges6 bronze badges
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.
answered May 23, 2016 at 20:58
Nouvel TravayNouvel Travay
6,15213 gold badges40 silver badges65 bronze badges
I uninstalled previous version. It worked for me.
answered Oct 5, 2018 at 2:47
![]()
I restarted my phone after uninstalling the app and it worked
answered Dec 4, 2018 at 10:10
If you have a different flavour of the app, try uninstalling that first. This helped me when I had the same issue.
answered Feb 24, 2020 at 11:36
olleholleh
1,78617 silver badges21 bronze badges
I had another app using a plugin with this permission authorities.
I uninstalled other apps which use this same package and all worked
answered May 8, 2022 at 23:06
![]()
Florian KFlorian K
1,8941 gold badge7 silver badges20 bronze badges
In this blog,
I have shown you when to come this issue and how to resolve it.
When to come
This is issue commonly comes in <5.1 version. Means Lollipop or greater version. And if you use the same permission in manifest then error shows,
INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.app.permission.C2D_MESSAGE pkg=com.app
How to resolve
We will give the example of GCM permission,
You can use the ${applicationId} on the place of packageName in AndroidManifest.xml file.
Replace
|
<permission android:name=«com.demoapp.webkul.permission.C2D_MESSAGE» android:protectionLevel=«signature»/> <uses-permission android:name=«com.demoapp.webkul.permission.C2D_MESSAGE»/> |
to
|
<permission android:name=«${applicationId}.permission.C2D_MESSAGE» android:protectionLevel=«signature»/> <uses-permission android:name=«${applicationId}.permission.C2D_MESSAGE»/> |
And in receiver’s intent-filter:
replace
|
<category android:name=«com.demoapp.webkul»/> |
to
|
<category android:name=«${applicationId}»/> |
And DUPLICATE_PERMISSION issue will be resolved.
. . .
20 ответов
Я нашел решение, которое работает для меня.
В моем устройстве (Nexus 7) Android 5.0. Lollipop Я следую этим шагам.
После удаления приложения Вы найдете App Name в списке приложений вкладки Downloaded.
- Перейдите в Настройки
- Приложения
- Внизу списка вы найдете
YourAppс тегом «NOT INSTALLED» - Открыть
- Нажмите
OptionMenuи выберите «Удалить для всех пользователей»
После этого процесса я успешно устанавливаю новое приложение, и оно работает хорошо.
Pratik Butani
13 дек. 2014, в 08:38
Поделиться
Удалите
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
Запустить приложение…
Затем добавьте permisson снова и запустите приложение.
Готов!.
Delmirio Segura
04 янв. 2015, в 16:13
Поделиться
У меня была та же проблема с пользовательским разрешением подписи на Android-21 и решила его, убедившись, что я делаю полную деинсталляцию.
Это краевой регистр, который возникает, когда:
- Приложение определяет настраиваемое разрешение с использованием безопасности уровня подписей
- Вы пытаетесь обновить установленное приложение версией, подписанной другим ключом.
- На тестовом устройстве работает Android 21 или новее с поддержкой нескольких пользователей.
Пример командной строки
Вот сценарий командной строки, который демонстрирует проблему и как ее решить. На этом этапе установлена версия отладки, и я пытаюсь установить производственную версию, подписанную с ключом выпуска:
# This fails because the debug version defines the custom permission signed with a different key:
[[email protected] svn-android-apps]# . androidbuildscripts/my-adb-install Example release
920 KB/s (2211982 bytes in 2.347s)
pkg: /data/local/tmp/Example-release.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.android.example.PERMISSION_EXAMPLE_PLUGIN pkg=com.example.android.example]
# I use uninstall -k because apparently that is similar to uninstalling as a user
# by dragging the app out of the app tray:
[[email protected] svn-android-apps]# /android-sdk-linux/platform-tools/adb uninstall -k com.example.android.example
The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell pm uninstall -k com.example.android.example'
# Let go ahead and do that:
[[email protected] svn-android-apps]# /android-sdk-linux/platform-tools/adb shell pm uninstall -k com.example.android.example
Success
# This fails again because the custom permission apparently is part of the data/cache
# that was not uninstalled:
[[email protected] svn-android-apps]# . androidbuildscripts/my-adb-install Example release
912 KB/s (2211982 bytes in 2.367s)
pkg: /data/local/tmp/Example-release.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.android.example.PERMISSION_EXAMPLE_PLUGIN pkg=com.example.android.example]
# In spite of the warning above, simply doing a full uninstall at this point turned out to
# work (for me):
[[email protected] svn-android-apps]# /android-sdk-linux/platform-tools/adb uninstall com.example.android.example
Success
# Release version now successfully installs:
[[email protected] svn-android-apps]# . androidbuildscripts/my-adb-install Example release
898 KB/s (2211982 bytes in 2.405s)
pkg: /data/local/tmp/Example-release.apk
Success
[[email protected] svn-android-apps]#
Пример Eclipse
Идти в обратном направлении (пытаясь установить сборку отладки из Eclipse, когда сборка релиза уже установлена), я получаю следующий диалог:

Если вы просто ответите «да» в этот момент, установка будет успешной.
Пример устройства
Как указано в другом ответе, вы также можете перейти на страницу сведений о приложении в настройках устройства, щелкнуть меню переполнения и выбрать «Удалить для всех пользователей», чтобы предотвратить эту ошибку.
x-code
23 нояб. 2014, в 16:37
Поделиться
Я решил это, не прибегая к деинсталляции альтернативного apk (что боль, правда?). Чтобы успешно установить как отладочную версию, так и версию apk, просто используйте gradle встроенный заполнитель ${applicationId} в AndroidManifest.xml, чтобы изменить значения имени android: name во время компиляции.
Фрагмент файла build.gradle:
buildTypes {
debug {
applicationIdSuffix ".debug"
...
}
}
Фрагмент файла AndroidStudio.xml:
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
Вы можете проверить измененный файл AndroidManifest.xml в apk с помощью aapt l -a app-debug.apk, чтобы убедиться, что местозаполнитель был правильно применен. Если вы используете различные вкусы продукта, я уверен, что вы можете применить вариант этого метода в соответствии с вашими потребностями.
Jackpile
31 дек. 2014, в 04:05
Поделиться
Удалите с вашего файла манифеста любую «жестко закодированную» ссылку вашего имени пакета.
(Это лучшая практика, даже если вы не используете productFlavors)
Например, если ваш манифест содержит:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="com.yourpackage.name.permission.C2D_MESSAGE"/>
<permission
android:name="com.yourpackage.name.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<permission
android:name="com.yourpackage.name.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
Изменено:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<permission
android:name="${applicationId}.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
Затем в вашем файле gradle установите соответствующий applicationId:
signingConfigs {
stage {
storeFile file('keystore/stage.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
production {
storeFile file('keystore/playstore.keystore')
storePassword store_password
keyAlias key_alias
keyPassword key_password
}
}
productFlavors {
staging {
signingConfig signingConfigs.staging
applicationId defaultConfig.applicationId + ".staging"
versionName defaultConfig.versionName + "-staging"
}
production {
signingConfig signingConfigs.production
}
}
Вы можете следовать этому руководству для получения дополнительной информации
David
02 май 2016, в 23:07
Поделиться
При предоставлении этой ошибки будет ясно указано имя пакета приложения, из-за которого было отказано в разрешении. И просто удаление приложения не решит проблему. Чтобы решить проблему, нам нужно сделать следующий шаг:
- Перейти к настройкам
- Перейти в приложение
- Перейдите в список загруженных приложений
- Вы можете увидеть удаленное приложение в списке
- Нажмите на приложение, перейдите к дополнительной опции
- Нажмите «Удалить» для всех параметров пользователя.
Задача решена: D
Preethi Rao
24 нояб. 2014, в 13:53
Поделиться
попробуйте удалить приложение с помощью adb:
adb uninstall com.yourpackage
Giuseppe
26 нояб. 2014, в 22:30
Поделиться
Установка приложения в OS 5.0 я получаю это сообщение:
INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.myapp.permission.C2D_MESSAGE pkg=com.myapp
Нет дублированных пакетов, и мы можем решить эту проблему, удалив вручную старое приложение или используя adb:
adb uninstall com.yourpackage
Jorgesys
27 янв. 2015, в 18:18
Поделиться
Ничто из этого не помогло мне. Мое приложение отлично работало раньше, чем Lollipop. Но когда я протестировал его на Lollipop, возникла ошибка выше. Он отказался установить. У меня не было установленных ранее версий, поэтому все вышеупомянутые решения недействительны в моем случае. Но благодаря этому SO-решению теперь он работает нормально. Как и большинство разработчиков, я следил за Google, вводящим в заблуждение учебник, и я добавил разрешения, скопировав и вставив их вот так:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.google.android.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
Это будет работать со старыми версиями < Леденец. Итак, теперь я изменил на:
<uses-permission android:name="com.mycompany.myappname.c2dm.permission.RECEIVE" />
<permission android:name="com.mycompany.myappname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
The_Martian
04 янв. 2016, в 01:45
Поделиться
В Android 5 проверьте свои настройки → приложения. Вместо того, чтобы удалять только активного пользователя (так как у android 5 может быть несколько пользователей, а мой телефон — гостевым пользователем), нажмите на кнопку аксессуара в правом верхнем углу панели действий/панели инструментов и выберите «удалить для всех пользователей». Похоже, что в Android 5, когда вы просто удаляете из пусковой установки, вы удаляете приложение только для активного пользователя.
Приложение все еще находится на устройстве. Это меня поразило, так как я пытался установить версию релиза, не работал, поэтому я думал, что должно быть так, потому что у меня все еще есть версия отладки, Но, чем все еще не удалось установить.. Первая подсказка была записью в списке приложений удаленного приложения с сообщением рядом с ним о том, что оно было удалено (изображение).


Jordy
28 дек. 2014, в 12:12
Поделиться
CommonsWare прав, но, на мой взгляд, это (ошибка) плохой способ сказать: «Установленный на устройстве apk подписан другим сертификатом, а затем новым, который вы пытаетесь установить».
Это, вероятно, новая ошибка, поскольку в прошлом она задавала вопрос о необходимости удаления приложения с устройства из-за неправильного сертификата.
Решение настолько болезненным, насколько это возможно, было бы удалить его вручную.
Кроме того, что мы сделали для разработки команды, мы добавили хранилище отладки в наш репозиторий и назовем gradle следующим образом:
android {
...
signingConfigs {
debug {
storeFile file("../certificates/debug.keystore")
}
}
...
buildTypes {
debug {
signingConfig signingConfigs.debug
}
}
...
}
И теперь, когда вы передаете устройства между членами команды, мы все используем один и тот же сертификат отладки, поэтому проблем нет.:)
TacB0sS
30 нояб. 2014, в 10:39
Поделиться
Я перезапустил свой телефон после удаления приложения, и он работал
Pedro Martins
04 дек. 2018, в 10:11
Поделиться
Я удалил предыдущую версию. Это сработало для меня.
Sushil Dhayal
05 окт. 2018, в 03:02
Поделиться
заменить ниже строки:
<permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
Sỹ Phạm
09 сен. 2016, в 04:52
Поделиться
В моем случае я использовал стороннюю библиотеку (например, вендор), а в библиотеке есть пример приложения, которое я уже установил на своем устройстве. Так что приложение-образец теперь конфликтует каждый раз, когда я пытаюсь установить собственное приложение, реализующее библиотеку. Поэтому я просто удалил приложение-образец поставщика, и он работает позже.
Nouvel Travay
23 май 2016, в 22:06
Поделиться
В вашем файле AndroidManifest.xml измените свои специально объявленные имена разрешений, например:
<!-- 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 -->
<!-- Creates a custom permission so only this app can receive its messages. NOTE: APP_PACKAGE.permission.C2D_MESSAGE -->
<permission android:name="com.myapprocks.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapprocks.permission.C2D_MESSAGE" />
<!-- END GCM -->
com.myapprocks эта часть решает конфликт с другим вашим приложением.
resw67
16 апр. 2016, в 09:39
Поделиться
В моем случае я получил следующую ошибку
Ошибка установки: INSTALL_FAILED_DUPLICATE_PERMISSION perm = com.map.permission.MAPS_RECEIVE pkg = com.abc.Firstapp
Когда я пытался установить приложение с именем пакета com.abc.Secondapp. Здесь было указано, что приложение с именем пакета com.abc.Firstapp уже установлено в моем приложении.
Я решил эту ошибку, удалив приложение с именем пакета com.abc.Firstapp, а затем установив приложение с именем пакета com.abc.Secondapp
Я надеюсь, что это поможет кому-то во время тестирования.
Abhinav Singh Maurya
06 окт. 2015, в 11:48
Поделиться
Я столкнулся с той же проблемой с Nexus 5 Android Lollipop 5.0.1:
Installation error: INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.android.** pkg=com.android.**
И в моем случае я не мог исправить эту проблему uninstalling, потому что это был android app, но мне пришлось изменить имя моего приложения custom permissions в manifest, потому что они были такими же, как и у Android приложение, которое я не смог удалить или изменить.
Надеюсь, это поможет кому-то!
Ultimo_m
23 дек. 2014, в 15:17
Поделиться
Раньше он говорил, что приложение с другой подписью находится на устройстве. При установке из IDE он также спросит, хотите ли вы его удалить?
Но я думаю, что с Android 5.0 они изменили причину деинсталляции. Это не происходит, если вы устанавливаете приложение с той же подписью
Yasir
25 нояб. 2014, в 03:46
Поделиться
Ещё вопросы
- 1Объем XML в Android
- 1невозможно получить доступ к ресурсу vue внутри действия vuex
- 1Java JLayeredPane не показывает его элементы
- 1ImagePanel не отображается в моем файле JAR с NetBeans
- 0добавьте <и>, войдите в ng-repeat и фильтруйте соответственно
- 1Android: плюсы / минусы ручной обработки изменений конфигурации
- 0функция неопределенная ссылка c ++
- 0В SQL или mySQL как найти ключ с наибольшей суммой в другом столбце, в то время как ключ отображается в двух столбцах?
- 0Не могу понять, как установить токен в заголовке моего запроса
- 0Почему JavaScript не меняет размер этого изображения?
- 0PHP Gettext, всегда пытается открыть файл перевода на английский
- 0Можно ли удалить определенные элементы из вектора на основе информации из другого вектора?
- 0Преобразование типов в свободных функциях
- 0Передача значений из родительской директивы в дочернюю директиву после возврата $ http
- 1Entity Framework — взаимодействовать с Orace и SQL Server
- 0Ошибка php / html в NetBeans
- 1MVC Web API AutoFac Dependency Injection
- 1C ++ CLR ошибка после добавления функции в .h файл
- 0Как определить, где находится «Ошибка» в файле сценария, используя Sublime Text 3
- 0Невозможно поделиться URL в твиттере с помощью строки запроса
- 0Почему код продолжает прыгать, возвращая main () ;?
- 1Лучший способ загрузить свойства навигации в новом объекте
- 1Измените тип объекта на его подтип и верните его
- 0связывание предустановленной библиотеки для каждого набора команд NDK
- 0Как использовать операторы WHERE и GROUP BY в сценарии MySQL?
- 1Невозможно установить свойства дочернего класса после асинхронного вызова конструктора базового класса. NodeJS v8.2.1
- 0Загрузка графика через Angular ngRoute не работает
- 0удалить подстроку из строки, введя первый и последний символ php
- 0Массивы внутри массива для хранения имен файлов
- 1Распознавание рукописного ввода для разных языков с использованием InkManager, C # XAML
- 1Ошибка веб-сайта фляги Python: запрошенный URL не найден на сервере
- 0Неправильная пользовательская директива Collapsable завершается неудачно, когда оборачивается вокруг содержимого ng-repeat
- 1Кэшируйте содержимое онлайн-файла в String, а не в локальный файл
- 1Кнопка «Избранное» в приложении Android (необходимо передать объект, не изменяя активность)
- 0Pdo Sqlite и php
- 1Заставить класс иметь конструктор
- 0Как отредактировать ячейку в listcontrol mfc?
- 1Доступ к защищенной WebHDFS Kerberos без SPnego
- 0Как заставить усечение (не масштабирование) при печати TCPDF
- 1JS Достижение и использование переменной родительского объекта
- 0Заставить браузер открывать новые окна в стиле SW_HIDE?
- 0добавить в переменную по переключателю кнопку php
- 1EntityFramework: доступ к закрытому закрытию
- 0Могу ли я использовать сервлет с Angular JS и реализовать архитектуру MVC?
- 0Я получаю пустые переменные через PHP форму электронной почты
- 1Android телефон развития
- 0Невозможно установить значение области для поля выбора
- 0Mysql: округляет дату и время — некоторые проблемы 24 часа
- 0Получение фактического идентификатора процесса команды, которая выполняется в фоновом режиме с использованием C ++
- 0HTML / CSS страница входа проблемы со стилем в IE не работает
Мой тестер сказал, что он не может установить приложение из Play Store на свой Nexus 5 (Lollipop). Он сказал, что получил эту ошибку
Unknown error code during application install "-505"
Я взял его телефон и попытался установить приложение через adb, я получил эту ошибку
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION
perm=com.example.gcm.permission.C2D_MESSAGE
pkg=com.mailchimp.alterego]
После некоторого чтения я наткнулся на это письмо с @Commonsware
http://commonsware.com/blog/2014/08/04/custom-permission-vulnerability-l-developer-preview.html
Очевидно, что и мое приложение, и приложение Mailchimp (которое установлено на моем телефоне тестера) имеют дублированное разрешение, com.example.gcm.permission.C2D_MESSAGE. Затем я проверяю журнал git, чтобы узнать, когда я добавил эту строку в свой AndroidManifest, и обнаружил, что это было, когда я реализую GCM. Тогда я следил за этим учебным пособием
https://developer.android.com/google/gcm/client.html

Я думаю, что и я, и разработчик Mailchimp следуют одному и тому же учебнику, добавили такое же разрешение, и теперь оба наших приложения имеют дублирующее разрешение.
Итак, я удаляю это разрешение с моего AndroidManifest, и теперь я могу установить приложение на свой тестер. Я тестирую сообщение GCM, отправляя пакет на сервер GCM с моего php script, и приложение все еще получало сообщение GCM, как было.
Итак, будет ли другая проблема поднята из-за этого отсутствующего разрешения и в чем смысл этого разрешения? (поскольку без него мое приложение все еще получало сообщение GCM)
Я беспокоюсь, если наше приложение использует плагин/библиотеку, требующую разрешения. Мы не сможем установить наше приложение на Lollipop-устройстве, если есть другое установленное приложение, которое использует одну и ту же библиотеку, не так ли?
— ПРИМЕЧАНИЕ —
Я уже прочитал этот вопрос, мало кто предлагает то же самое, что и я, удалить разрешение. Но никто не говорит о том, что произойдет после того, как мы это сделаем, или почему мы должны добавить его.
INSTALL_FAILED_DUPLICATE_PERMISSION… C2D_MESSAGE
— ИЗМЕНИТЬ 1 —
Я вернулся к учебнику, руководство было правильным, это была неправильная реализация

I (и разработчик Mailchimp) должен добавить разрешение с именем нашего пакета приложений + «.permission.C2D_MESSAGE» вместо копирования и вставки com.example.gcm.permission.C2D_MESSAGE
<permission android:name="com.mycompany.myappname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
Но, это поднимает мне еще один вопрос, учебник сказал, что если мы не добавим это разрешение или имя не будет соответствовать шаблону, приложение не получит сообщение. Но я получил сообщение, когда я тестирую даже когда я удаляю это pemission… странно.
I recently upgraded to onesingal@3.0.7 and everything seemed to be working correctly until I tried to reinstall the app on my development phone.
The error I get is: Failed to finalize session : INSTALL_FAILED_DUPLICATE_PERMISSION: Package com.example attempting to redeclare permission com.example..permission.C2D_MESSAGE already owned by com.example
I reinstall by running:
adb install -r myapp.apk
I do this because I don’t want to lose the data I have locally. This used to work fine in the past, but now it’s no longer working.
The first time I reinstalled it after the upgrade it was fine. But after installed it, made some updates, then tried to reinstall it again, it failed with the error mentioned above.
I checked my app to see if that permission was declared anywhere else, it wasn’t. The only place it was defined were in the one-signal build folders.
Please let me know if there’s a way I can reinstall my app without losing all my existing data.
Thanks!
Phone: 6.0.1
react-native 0.49.5
minSdkVersion: 16
targetSdkVersion: 22
react-native-onesignal: 3.0.7
(, если вы пришли сюда путем поиска в Google, чтобы найти решение этой ошибки, ниже ссылки дадут вам ответ, также мой вопрос имеет своего рода объяснение!)
Возможный дубликат
INSTALL_FAILED_DUPLICATE_PERMISSION… C2D_MESSAGE Ошибка -505 INSTALL_FAILED_DUPLICATE_PERMISSION
< Сильный > Подождите !
Я получил эту ошибку сегодня в живом проекте. Пользователь пришел с ошибкой 505, не удалось установить приложение. Затем я запустил его в IDE!
- Если вы загрузите приложение с упомянутой проблемой из магазина Play, вы получите ошибку 505 при попытке установить.
- Если вы попытаетесь запустить его с помощью IDE, вы получите ошибку, как на картинке выше! (поправьте меня, если я ошибаюсь)
Тогда я искал причины.
Это была моя проблема!
<permission
android:name="in.wptrafficanalyzer.locationroutedirectionmapv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="in.wptrafficanalyzer.locationroutedirectionmapv2.permission.MAPS_RECEIVE" />
Сюрпризом было то, что приложение другого разработчика на телефоне конкретного пользователя использовало ту же подпись! Черт, эти копировальные пасты встретились сегодня !!
Я думаю, что если я попытаюсь объявить одно и то же разрешение в двух приложениях с то же имя пакета , эта ошибка может возникнуть (исправьте меня, если я ошибаюсь)
Вот мои 2 вопроса?
1. Должны ли они быть с таким же разрешением ? в любом случае они получат эту вещь, когда она такая же. Допустим, приложение A использует для пользователя приложение pkg.name с разрешением permission.RECEIVE приложение B использует один и тот же пакет с другим разрешением CONFIGURE_SIP. Может ли это произойти, когда они встречаются? (кажется глупым вопросом, но я хочу подтвердить у другого приложения, которое было там в мобильном телефоне клиента, было то же самое!)
2. Каковы / могут быть какие-либо другие возможности возникновения этой ошибки?
- Приложение определяет настраиваемое разрешение с использованием безопасности на уровне подписи
- Вы пытаетесь обновить установленное приложение версией, подписанной другим ключом
- Тестовое устройство работает под управлением Android 21 или более поздней версии с поддержкой нескольких пользователей
Получил эти 1 2 3 из этой записи! Они правда? Если да, то какое-либо хорошее объяснение о них будет хорошим или какая-либо дополнительная причина этой ошибки?
В упомянутых постах много хороших ответов! Не спрашиваю, как это исправить! Но как это генерируется! Также, если я упомянул / понял что-то не так, пожалуйста, запишите это !!
Спасибо.
Изменить : Как я уже упоминал, обратите внимание, что проблема возникла в приложении, которое уже есть в Play Store. А про другое приложение я понятия не имею! Он есть в мобильном телефоне клиента. Вероятно, он также из магазина игр, потому что даже опции разработчика не были активированы, пока я не попытался запустить на этом мобильном телефоне. У него также не было никаких предыдущих приложений от моей компании. Он просто пытался загрузить приложение, полученное Ошибка 505 и пришел, чтобы исправить это.
Кроме того, моим первым вариантом было удаление этого разрешения и успешная установка приложения (не то, что нужно, но чтобы подтвердить, где была проблема). Вот почему мне нужно знать возможности этой ошибки!
2 ответа
Лучший ответ
Блоги @commonsware подробно объясняют это в Уязвимость в пользовательском разрешении и предварительный просмотр ‘L’ для разработчиков:
Насколько я могу судить, «L» Developer Preview требует, чтобы все приложения с элементом
<permission>для того же значения android: name будет подписано по тому же ключу подписи. ФактическиеprotectionLevelили другие значения внутри<permission>не имеет значения. Даже если они идентичны, приложение, пытающееся определить<permission>, не сможет установить, если Существующее установленное приложение уже определяет<permission>. В частности , установка второго приложения не удастся с Ошибка INSTALL_FAILED_DUPLICATE_PERMISSION .
Вот ответ от @commonsware: https://stackoverflow.com/a/11730133/4758255
0
ישו אוהב אותך
4 Фев 2017 в 07:37
Ваша проблема не в разрешениях. Невозможно иметь два приложения с одинаковым именем пакета манифеста, оно должно быть уникальным. Итак, система думает, что пользователь пытается переустановить / обновить старое приложение с новым сертификатом подписи. От разработчиков Android. блог
Если сертификат подписи изменится, попытка установить новое приложение на устройстве не удастся, пока старая версия не будет удалена.
РЕДАКТИРОВАТЬ:
Я запускаю несколько тестов с разрешениями. Я думаю, что поведение очень похоже на имя пакета приложения. Ошибка возникает только при совпадении на 100%. Результаты: приложение A (пакет test.test) и приложение B (пакет test.test2)
package="test.test">
<permission
android:name="test2.example.h"
android:protectionLevel="signature" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.test2">
<permission
android:name="test.example.hr"
android:protectionLevel="signature" />
- разрешение A — test.example.h против B — test.example.h — ошибка DUPLICATE_PERMSSIONS
- test.example vs test.example.h — успех
- test.example.g vs test.example.h — успех
uses-permission не влияет на ошибки / установки. Но я думаю, что вы можете получить SeciurityException во время выполнения, если попытаетесь использовать другие разрешения.
0
Charuක
1 Фев 2017 в 13:14
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.
23 Answers
I’ve found a solution that works for me.
In My Device (Nexus 7) Android 5.0. Lollipop I follow these steps.
After Uninstalling App You will find App Name under Apps List of the Downloaded tab.
- Go to Settings
- Apps
- At the bottom of the list, you will find
YourAppwith a «NOT INSTALLED» Tag - Open
- Click on
OptionMenuand Select «Uninstall for all Users»
After these steps, I successfully install the new app and it’s running well.
Remove
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
Run App…
Then Add the permisson again and Run App.
Ready!.
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:
- An application defines a custom permission using signature level security
- You attempt to update the installed app with a version signed with a different key
- The test device is running Android 21 or newer with support for multiple users
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:
# This fails because the debug version defines the custom permission signed with a different key:
[[email protected] svn-android-apps]# . androidbuildscripts/my-adb-install Example release
920 KB/s (2211982 bytes in 2.347s)
pkg: /data/local/tmp/Example-release.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.android.example.PERMISSION_EXAMPLE_PLUGIN pkg=com.example.android.example]
# I use uninstall -k because apparently that is similar to uninstalling as a user
# by dragging the app out of the app tray:
[[email protected] svn-android-apps]# /android-sdk-linux/platform-tools/adb uninstall -k com.example.android.example
The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell pm uninstall -k com.example.android.example'
# Let's go ahead and do that:
[[email protected] svn-android-apps]# /android-sdk-linux/platform-tools/adb shell pm uninstall -k com.example.android.example
Success
# This fails again because the custom permission apparently is part of the data/cache
# that was not uninstalled:
[[email protected] svn-android-apps]# . androidbuildscripts/my-adb-install Example release
912 KB/s (2211982 bytes in 2.367s)
pkg: /data/local/tmp/Example-release.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.android.example.PERMISSION_EXAMPLE_PLUGIN pkg=com.example.android.example]
# In spite of the warning above, simply doing a full uninstall at this point turned out to
# work (for me):
[[email protected] svn-android-apps]# /android-sdk-linux/platform-tools/adb uninstall com.example.android.example
Success
# Release version now successfully installs:
[[email protected] svn-android-apps]# . androidbuildscripts/my-adb-install Example release
898 KB/s (2211982 bytes in 2.405s)
pkg: /data/local/tmp/Example-release.apk
Success
[[email protected] svn-android-apps]#
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.
I’ve solved this without having to resort to uninstalling the alternate apk first (what a pain, right?). To successfully install both a debug and release version of an apk, simply use gradle’s built-in ${applicationId} placeholder within the AndroidManifest.xml to modify the permissions’ android:name values at compile time.
The build.gradle file snippet:
buildTypes {
debug {
applicationIdSuffix ".debug"
...
}
}
The AndroidStudio.xml file snippet:
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
You can inspect the modified AndroidManifest.xml file within the apk using aapt l -a app-debug.apk to ensure the placeholder was properly applied. If you use various product flavors, I’m sure you can apply a variation of this method to suit your needs.
Remove any «Hard Coded» reference of your package name, from your manifest file.
(This is best practice even if you don’t using productFlavors)
For example, if your manifest contains:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="com.yourpackage.name.permission.C2D_MESSAGE"/>
<permission
android:name="com.yourpackage.name.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<permission
android:name="com.yourpackage.name.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
Changed it to:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<permission
android:name="${applicationId}.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
Then, in your module gradle file, set your relevant applicationId:
signingConfigs {
stage {
storeFile file('keystore/stage.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
production {
storeFile file('keystore/playstore.keystore')
storePassword store_password
keyAlias key_alias
keyPassword key_password
}
}
productFlavors {
staging {
signingConfig signingConfigs.staging
applicationId defaultConfig.applicationId + ".staging"
versionName defaultConfig.versionName + "-staging"
}
production {
signingConfig signingConfigs.production
}
}
You can follow this tutorial for more info
try to uninstall the app with adb:
adb uninstall com.yourpackage
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:
- Go to settings
- Go to app
- Go to downloaded app list
- You can see the uninstalled application in the list
- Click on the application, go to more option
- Click on uninstall for all users options
Problem solved 😀
Installing an application in OS 5.0 i get this message:
INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.myapp.permission.C2D_MESSAGE pkg=com.myapp
There´s no duplicated packages, and we can solve this issue uninstalling manually the old application or using the adb:
adb uninstall com.yourpackage
None of the above worked for me. My app was working fine in previous than Lollipop. But when I tested it on Lollipop the above error came up. It refused to install. I didn’t have any previous versions installed so all the above solutions are invalid in my case. But thanks to this SO solution now it is running fine. Just like most developers I followed Google’s misleading tutorial and I added the permissions by copy and paste like this:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.google.android.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
This would work with older versions < Lollipop. So now I changed to:
<uses-permission android:name="com.mycompany.myappname.c2dm.permission.RECEIVE" />
<permission android:name="com.mycompany.myappname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
CommonsWare is right, but in my opinion this is a (bug)poor way to say: «The apk installed on the device is signed with a different certificate then the new one you are trying to install».
This is probably a new bug since in the past it used to ask whether or not to uninstall the app from the device due to wrong certificate.
The solution as painful as it may be would be to uninstall the app it manually.
Also what we’ve done for the sake of team development, we added the debug keystore to our repository, and point gradle to use it like so:
android {
...
signingConfigs {
debug {
storeFile file("../certificates/debug.keystore")
}
}
...
buildTypes {
debug {
signingConfig signingConfigs.debug
}
}
...
}
And now when passing devices between team members, we all use the same debug certificate, so there is no issue. 🙂
In Android 5, check your settings -> apps. Instead of deleting for just the active user (since android 5 can have multiple users and my phone had a guest user) tap on the accessory button in the top right corner of the action/toolbar and choose «uninstall for all users». It appears that in Android 5 when you just uninstall from launcher you only uninstall the app for the active user.
The app is still on the device.. This had me dazzled to since I was trying to install a release version, didn’t work so I thought ow right must be because I still have the debug version installed, uninstalled the app. But than still couldn’t install.. First clue was a record in the app list of the uninstalled app with the message next to it that it was uninstalled (image).


See this link it said that it will work when they are signed by the same key. The release key and the debug key are not the same.
So do it:
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release//signing by the same key
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt'
}
debug {
applicationIdSuffix ".debug"
debuggable true
signingConfig signingConfigs.release//signing by the same key
}
}
signingConfigs {
release {
storeFile file("***\key_.jks")
storePassword "key_***"
keyAlias "key_***"
keyPassword "key_"***"
}
}
replace below lines:
<permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
In my case, I had several applications installed having the same domain name in the package name as follows.
com.mypackage.app1
com.mypackage.app2
com.mypackage.app3
...
I had to uninstall all the apps having similar package names and reinstall them again in order to get rid of the problem.
To find all package names from the device I used the following.
adb shell pm list packages
Then I grabbed the packages that match my package name that I am looking for.
dumpsys | grep -A18 "Package [com.mypackage]"
Then uninstalled all the apps having that domain.
uninstall com.mypackage.app1
uninstall com.mypackage.app2
uninstall com.mypackage.app3
...
You can also uninstall the applications using the Settings app. Go to the Settings -> Apps -> Find the app -> Uninstall
Hope that helps someone having the same problem as me.
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
I encountered the same problem with a nexus 5 Android Lollipop 5.0.1:
Installation error: INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.android.** pkg=com.android.**
And in my case I couldn’t fix this problem uninstalling the app because it was an android app, but I had to change my app custom permissions name in manifest because they were the same as an android app, which I could not uninstall or do any change.
Hope this helps somebody!
In my case I received following error
Installation error: INSTALL_FAILED_DUPLICATE_PERMISSION
perm=com.map.permission.MAPS_RECEIVE pkg=com.abc.Firstapp
When I was trying to install the app which have package name com.abc.Secondapp. Here point was that app with package name com.abc.Firstapp was already installed in my application.
I resolved this error by uninstalling the application with package name com.abc.Firstapp and then installing the application with package name com.abc.Secondapp
I hope this will help someone while testing.
In your AndroidManifest.xml file, change your specially declared permissions’ names, for example:
<!-- 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 -->
to this,
<!-- Creates a custom permission so only this app can receive its messages. NOTE: APP_PACKAGE.permission.C2D_MESSAGE -->
<permission android:name="com.myapprocks.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapprocks.permission.C2D_MESSAGE" />
<!-- END GCM -->
com.myapprocks this part solves the conflict with your other app.
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.
I uninstalled previous version. It worked for me.
I restarted my phone after uninstalling the app and it worked
If you have a different flavour of the app, try uninstalling that first. This helped me when I had the same issue.
For making the application & its multiple instance you can directly add this line then you can able to install the multiple application with same package name every time just modify the application id:
Example : application id : XXXX.123 (Old or existing one which is installed in phone)
Now make application id as : XXX.1234 and install the app.
Format:
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
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.
TL;DR
This issue occurs when an app is trying to re-declare an existing permission, with error message INSTALL_FAILED_DUPLICATE_PERMISSION. It mainly affected apps that are based on Adobe AIR (package prefix with com.air). The main cause is the different code implementation in Lollipop 5.0 when verifying a certificate’s signature used to sign an app. For the solution, just skip over to the «Solution» part.
Update: Google has fixed this issue on Lollipop 5.0.1.
Technical Details
Excerpts from Android L Developer Preview issue tracker which are linked from an entry on AOSP issue tracker,
Post #4:
logcat tells me there’s a conflict with redeclaring permissions during installation (in my case, Amazon is trying to redeclare getui.permission.GetuiService, which is already owned by Camera 360)
Post #12’s LogCat:
10-25 08:06:37.805 749 824 W PackageManager: Package com.tencent.mm attempting to redeclare permission com.google.android.c2dm.permission.SEND already owned by com.google.android.gsf
10-25 08:06:37.926 4812 4812 D Finsky : [1] PackageInstallerImpl.cancelSession: Canceling session 121130466 for com.tencent.mm
10-25 08:06:37.926 4812 4812 E Finsky : [1] PackageInstallerImpl.handleCommitCallback: Error -505 while installing com.tencent.mm: INSTALL_FAILED_DUPLICATE_PERMISSION: Package com.tencent.mm attempting to redeclare permission com.google.android.c2dm.permission.SEND already owned by com.google.android.gsf
10-25 08:06:37.926 4812 4812 W Finsky : [1] 4.installFailed: Install failure of com.tencent.mm: -505 null
10-25 08:06:37.933 749 749 D ZenLog : intercepted: 0|com.android.vending|-973170826|null|10017,!priority
10-25 08:06:37.933 749 749 V NotificationService: pkg=com.android.vending canInterrupt=false intercept=true
10-25 08:06:37.964 4812 4812 D Finsky : [1] InstallerTask.cancelCleanup: Cancel running installation of com.tencent.mm
Excerpts from AOSP issue tracker,
Post #4
In API19 the new X509CertImpl(encCert) wraps the certificate (which is already parsed and ready for SHA1 computation), while in API 21, the certificate is forwarded as byte stream, parsed again and processed by a certificate factory. Which factory that is, depends on the context. In case of the L devices I tested on, the factory will create an OpenSSLX509Certificate. Unfortunately, there is something in our certificate which openssl has trouble with and the fingerprint changes during openssl processing. I can reproduce this also with the openssl tool, when I convert our certificate into some other format (e.g., PEM).
If the SHA1 would be computed directly on ‘encCert.getEncoded()’ it would be correct in both cases.
Solution
Update: As of 2014-12-04, Google has fixed this issue on Lollipop 5.0.1. For those who didn’t do any workaround trying to reinstall the app, you can flash Lollipop 5.0.1 image when it’s ready/wait for the OTA.
Post #20, #21
Looks like this has been fixed in 5.0.1:
https://android.googlesource.com/platform/libcore/+/6632d8c9d8d1a3ac338d541676148677641bafe3
https://android.googlesource.com/platform/frameworks/base/+/32a22c44b8351c1cccd3a1f9c47a33469d9378e0
Status: Released
Committer’s note
Recover apps with malformed certificates.
There was a window of time in Lollipop where we persisted certificates
after they had passed through a decode/encode cycle. The well-written
OpenSSL library was liberal when decoding (allowing slightly malformed
certs to be parsed), but then strict when encoding, giving us
different bytes for effectively the same certificate.A related libcore change (0c990ab4a90b8a5492a67b2b728ac9a4a1ccfa1b)
now returns the original bytes verbatim, fixing both pre-Lollipop
installs and installs after that change.This change recovers any apps that had been installed during the
window of time described above by doing a one-time check to see if
the certs are effectively equal.
Please refer to older revision for other suggested solutions.
Ive wrote an app. Everthing was fine but then i wanted to work on it on my computer at home. The problem is that i receive the error message «INSTALL_FAILED_DUPLICATE_PERMISSION» when i want to start the app in the emulator. At work I use the same settings for the emulator. And there werent problems with other apps when i tried to work on it on 2 different computers.
Sorry if I havent gave u enough informations, but i am new in programming.
Maybe somebody have made similar experiences and could help me with it.
Thanks in Advance!
asked May 31, 2021 at 14:07
1
You can use the ${applicationId} on the place of packageName in AndroidManifest.xml file.
Replace
<permission
android:name="com.example.testapp.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.testapp.permission.C2D_MESSAGE"/>
to
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
And in receiver’s intent-filter:
replace
<category android:name="com.example.testapp"/>
to
<category android:name="${applicationId}"/>
And DUPLICATE_PERMISSION issue will be resolved.
answered Feb 24, 2022 at 12:38
