INSTALL_FAILED_CONFLICTING_PROVIDER in Android
Asked Answered
F

10

21

I am using an open-srouce code from Google for an app called MyTracks.

I am getting this error when the original app is installed on the phone.

INSTALL_FAILED_CONFLICTING_PROVIDER

I know that this is because of the android:authorities in the Manifest.

here is the part of the Manifest:

<provider
android:name="com.google.android.apps.mytracks.content.MyTracksProvider"
android:authorities="com.google.android.maps.mytracks"
android:exported="true"
android:readPermission="com.google.android.apps.mytracks.READ_TRACK_DATA"
android:writePermission="com.google.android.apps.mytracks.WRITE_TRACK_DATA" />
<!-- Search suggestion provider -->
<provider
android:name="com.google.android.apps.mytracks.content.SearchEngineProvider"
android:authorities="com.google.android.maps.mytracks.search"
android:exported="false" />

So, my question is: I want to know whether this approach may solve the problem or not, because I am afraid of changing all the packages names and then have the whole app broken.

  1. The android :authorities value is the package name. The android:name is the name of the class of that provider. Am I correct?

If I change the package name, to another one different than the com.google etx, and rename all the references/ imports of that package, should the problem go away?

Fugue answered 21/1, 2014 at 23:31 Comment(0)
S
34

The android :authorities value is the package name.

In this case, it happens to be the package name. It simply has to be unique.

The android:name is the name of the class of that provider

Correct.

If I change the package name, to another one different than the com.google etx, and rename all the references/ imports of that package, should the problem go away?

The package name has nothing to do with it. You may need to change that as well, though, for your app to be able to be installed alongside the regular, un-modified app.

You need to have a unique value for android:authorities, and the code in your app that uses this ContentProvider needs to use an appropriate Uri (content://whatever.you.change.the.authority.to/...).

Smolder answered 21/1, 2014 at 23:45 Comment(3)
I have change the applicationId for each of my flavor. But I am getting above mention error.Dodiedodo
it is possible that I an run same app with different varient in same device. Which react as different application in same device?Dodiedodo
@iDroidExplorer: The question is about content provider authorities. Build variants do not matter directly here -- the authorities must still be unique. You can use placeholders in the manifest merger process to have the authority string be based on the build variant's applicationId, though. For example, use android:authorities="${applicationId}.provider" to have the authority string be the applicationId` with .provider appended.Smolder
E
7

If you are using Google Maps + Google Play Services inside a library project, you can encounter this error when you try to run an app that uses your library, while a different app that uses the same library is already installed on your device.

Fix: make sure that defaultConfig.applicationId is defined in android section of the build.gradle file for each project using your library

android {
    defaultConfig.applicationId = "com.company.appname"
}

I would recommend using the package name of the specific app. With this fix, the provider names will no longer conflict, and your app will run as expected.

Symptoms

1.) Your users are seeing the dreaded "-505" install error when installing your app from the Play Store.

2.) You will see this error message when you try to install a second app that uses your library via Android Studio:

enter image description here

In your console, you will see a message like this:

Package couldn't be installed in /data/app/com.company.appname-1
com.android.server.pm.PackageManagerException: 
Can't install because provider name 
com.google.android.gms.measurement.google_measurement_service 
(in package com.company.appname) is already used by
com.company.otherInstalledAppName

The fix is to make sure that defaultConfig.applicationId is defined in android section of the build.gradle file for each project using your library

android {
    defaultConfig.applicationId = "com.company.appname"
}

More reading can be found here in the original bug report: Issue 784: Multiple apps using same authority provider name

Evacuee answered 18/1, 2016 at 22:27 Comment(0)
C
6

just uninstall helloFacebooksample app from you device

Cofield answered 15/1, 2015 at 21:4 Comment(0)
H
5

if you use for ex facebook-sdk then for each app you need unique this line in manifest

<provider android:authorities="com.facebook.app.FacebookContentProviderxxxxxxxxxx"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>

xxxxxxxxxx - should be unique for each app, for facebook-sdk it's your facebook_id number

Hurdle answered 28/9, 2016 at 19:39 Comment(1)
Addition to the answer: if you are testing 2 different versions of your app with facebook integration, then you can sign in to the facebook developer dashboard, go to your app, in the top left click on the name of your app, in the menu click + Create Test App. This will create a test app with another app ID. Use it for the test version of your app.Emancipator
B
3

I got this same error when I changed the package name in my app's manifest. This creates a conflict when you try to install the app again (with the new package name). The solution is to remove the old version of the app (that uses the old package name), then you'll be able to install the new version.

Bistoury answered 17/12, 2014 at 12:42 Comment(3)
What if someone want to install both version. For example beta version of the app?Responsion
Hiya Shajeel. I've never tried it, but I presume you'd have the same problem - unless you know any better?Bistoury
Actually the problem was with the authority of the Provider declared in the manifest, after changing the package i had to manually change the authority and now it is working.Responsion
G
3

Just Uninstall the application from the device which you are trying to run and try to reinstall application again. The existing application is conflicting with the new one.

Galore answered 21/10, 2019 at 4:56 Comment(2)
is there a way to make Android Studio do it automatically?Berard
@GeorgeShalvashvili, Not that I am aware of.Galore
I
1

The gradle also needs to contain this

defaultConfig {
  applicationId "com.example.app"
}

I had left it out completely

Ilene answered 4/7, 2016 at 6:7 Comment(0)
D
1

CommonsWare has it right, however, there are more details that may help.

For me, there were two key parts of the solution. First I added $(applicationId) to Manifest provider entry:

        <provider
            tools:replace="android:authorities"
            android:name="android.support.v4.content.FileProvider"
            android:authorities="${applicationId}.files"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/fileprovider" />
        </provider>

Second, when you switch Build Varients, and for me this is between 'debug' and 'release', you also need to Sync Project with Gradle Files. It was not enough to just Clean and Rebuild project.

In Android Studio there are two tabs in the bottom of the AndroidManifest.xml page. The 'Text' tab you use to edit and the 'Merged Manifest' tab shows the resulting manifest after the build, and for me I can see it was injecting the applicationId properly into the android:authorities section of the provider.

Dogs answered 24/1, 2019 at 17:31 Comment(0)
C
0

You maybe compile same library or including libraries. For example :

compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'

Above code, google play services (first line ) includes all other services .

Concordat answered 11/1, 2016 at 13:3 Comment(0)
B
-3

may be your phone memory is full so please check it

Back answered 16/3, 2017 at 10:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.