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.
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.
Overview of the Facebook SDK for AndroidThe SDK is open source, and it is hosted at GitHub's facebook / facebook-android-sdk repository.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With