Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio: INSTALL_FAILED_CONFLICTING_PROVIDER facebook sdk

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.

like image 415
giozh Avatar asked Apr 27 '15 10:04

giozh


People also ask

What is the Facebook SDK?

The Facebook SDK is a set of software components that developers can include in their mobile app to understand how people use the app, run optimized marketing campaigns and enable Facebook login and social sharing. This course helps you understand the purpose of the Facebook SDK and App Events for Android and iOS.

Is Facebook SDK open source?

Overview of the Facebook SDK for AndroidThe SDK is open source, and it is hosted at GitHub's facebook / facebook-android-sdk repository.


Video Answer


1 Answers

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.

like image 117
Simon Avatar answered Sep 22 '22 16:09

Simon