Android studio: INSTALL_FAILED_CONFLICTING_PROVIDER facebook sdk
Asked Answered
T

5

12

I'm facing a strange problem with android studio. I have two Android app that uses facebook sdk with same facebook Application for login and share pictures. With new api, it's necessary to declare inside manifest this:

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

Now if one of that app is already installed on device and i try to install the second one, i obtain this error on Android studio:

INSTALL_FAILED_CONFLICTING_PROVIDER

It's necessary a problem of facebook provider, that is the only element inside my app. So, in this way my two apps couldn't be installed at the same time on the same device? I would like if there's a way for use same provider and avoid that error.

Tiger answered 27/4, 2015 at 10:54 Comment(3)
You should have to Create an Another Application in Facebook Developer Console and assign the Other App id to Your App and Integrate it with Your thid Manifest Provider Entry and You are able to do that.Carbazole
Two apps belongs to the same Facebook app. It's not possible to create two distinct applicationsTiger
Did you ever find a workaround for this? Was thinking if it was possible to disable the ContentProvider in Debug versions. Still researching the problem. Of course this will disable sharing capabilities for that version.Barnyard
A
16

This is an old question I know, but there wasn't a clear-cut answer to this that I could find. Thought I'd post how I've done it.

You can't have two different apps (or the same app using two different application ids) using the same Facebook App Id. This breaks the ContentProvider stuff. You need to create a test app under your main app on the Facebook developer area. Then take the new app ID from there and keep it handy.

Next, in your build.gradle, add (or append) the following entry to your defaultConfig block.

    manifestPlaceholders = [ facebook_app_id:"" ]

Then in your debug config add:

    manifestPlaceholders = [ facebook_app_id:"<the_debug_app_id_you_kept_handy>"]

Then in your release config add:

    manifestPlaceholders = [ facebook_app_id:"<the_original_app_id_you_had>" ]

Now, change your AndroidManifest.xml. Change:

    <provider android:authorities="com.facebook.app.FacebookContentProvider<original_app_id>"

to:

    <provider android:authorities="com.facebook.app.FacebookContentProvider${facebook_app_id}"

and, change:

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="<original_app_id>"/>

to:

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="${facebook_app_id}"/>

That should do it. What you've done is add a placeholder to the manifest. Essentially it's a variable, that you can then set your gradle build to populate its value with different things based on the build type or flavor.

Armour answered 22/2, 2016 at 15:29 Comment(2)
Thanks helped me resolve my issue of an app with different applicationIdsThermopylae
Thanks for the solution. You saved quite a lot of time.Brownfield
T
4

So, in this way my two apps couldn't be installed at the same time on the same device?

Correct.

I would like if there's a way for use same provider and avoid that error.

The following has nothing to do with Facebook's SDK, but deals only with Android and its limits. Facebook's SDK may impose new and exciting limits.

In theory, you could say that App A has the <provider> and App B uses the provider from App A. This implies that App B cannot be used on its own. When the user runs the app, you would have to check to see if App A is installed and force the user to install it in order to be able to use App B. This may cause some amount of user angst. If you want both App A and App B to be usable individually, that is fine, but then both will have to have the <provider> and then they cannot both be installed at the same time.

Ideally, you would solve this by having both <provider> elements be disabled (android:enabled="false") at the outset. Then, whoever runs first would elect itself to be the one offering the provider for that device, at which point it would enable the provider. Alas, due to an Android bug/limitation, this will not solve the problem, as you will not be able to have both installed at the same time anyway.

I tend to agree with Rajan Bhavsar's comment. Either you need to have one Android app for your one Facebook app ID, or you need two Facebook app IDs for your two Android apps.

Turban answered 27/4, 2015 at 11:22 Comment(4)
It's a particular situation, where two apps are for two different type of phisical user (one app do a subset of operation of the other one), but it never happen that a user can have both application installed at the same time on the same device. It's only annoying during test phase on phisical device (i need to uninstall one app if i would try the other one).Tiger
@giozh: Then your current approach is probably your best answer. You might consider writing yourself a Gradle task that uninstalls the other app and installs the one you are trying to work with, that you can invoke to rapidly switch between them. Or, use two physical devices. And, for all I know, Facebook has some other solution for this problem that is specific to the way they require those authorities to be set up.Turban
I know this discussion is a year old, but it seems that Facebook's own documentation suggests that a developer should be able to use the same app ID across multiple Android apps (developers.facebook.com/docs/android/…), they just don't explain how to get around this issue. (Same for iOS: developers.facebook.com/docs/ios/troubleshooting#sharedappid)Dundalk
but what about this : You can use one Facebook app ID in multiple Android apps. Just use the same app ID in another app for login, sharing, and so on. For deep linking and opening your app through notifications and other means, we only support a single package name/class name combination. If you want multi-app support for deep linking, see App Links.Kimikokimitri
J
3

As far as I can see there is no requirement on the name for the android:autorities in the respective provider node (https://developer.android.com/guide/topics/manifest/provider-element.html), so you could make the URI unique by injecting the applicationId:

android:authorities="${applicationId}.com.facebook.app.FacebookContentProvider[app_id]
Joust answered 17/5, 2016 at 2:35 Comment(0)
T
0

Inside your manifest

  <provider
                android:name="com.facebook.FacebookContentProvider"
                android:authorities="@string/authority"
                android:exported="true" />

Inside your gradle

 productFlavors {
 appStore{
            applicationId "store_app"
            resValue "string", "authority", "com.facebook.app.FacebookContentProviderStoreApp"
        }
       }
Trincomalee answered 25/11, 2018 at 14:8 Comment(0)
R
-3

So you can change the provider name from one of your app. Use App name Inst ed of App_id.

Riata answered 1/8, 2015 at 18:55 Comment(1)
The appId is the id given from the facebook developer console and has to match that given id.Visional

© 2022 - 2024 — McMap. All rights reserved.