INSTALL_FAILED_CONFLICTING_PROVIDER using the Facebook SDK when I create several products.

I am creating an Android application with several productFlavors and use the Facebook SDK v4.1 to login and share content. The problem is that when I try to install an application on a device that already has the same application installed (but differs from another), it causes an error. This does not allow me to install the second application unless I uninstall the existing one.

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

Accordingly, android:authorities must be unique, and I must have several auths to accomplish what I want to do. However, I cannot have multiple Facebook apps, and I was wondering if there is a better way to solve this problem. Thanks in advance to everyone who can help me!

+7
source share
3 answers

Try the following:

Manifest

 <provider android:authorities="com.facebook.app.FacebookContentProvider${facebookId}" android:name="com.facebook.FacebookContentProvider" android:exported="true" /> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb${facebookId}"/> 

Gradle

 android { compileSdkVersion 25 buildToolsVersion "25.0.1" defaultConfig { applicationId "com.your.package" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" manifestPlaceholders = [facebookId:"123456789"] } productFlavors { debug { applicationIdSuffix ".debug" manifestPlaceholders = [facebookId:"1234"] } release { applicationIdSuffix ".pro" manifestPlaceholders = [facebookId:"123456789"] } } 
+6
source

You can use this:

manifest

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

Gradle

 productFlavors { flavor1 { applicationId "com.id.flavor1" versionCode 1 versionName "1.0.0" resValue "string", "facebook_app_authority", "com.facebook.app.FacebookContentProvider0000000000000000" } flavor2 { applicationId "com.id.flavor2" versionCode 1 versionName "1.0.0" resValue "string", "facebook_app_authority", "com.facebook.app.FacebookContentProvider0000000000000001" } } 

Replace 0000000000000000 with your application id

-1
source
 <provider android:authorities="com.facebook.app.FacebookContentProvider{app id here}" android:name="com.facebook.FacebookContentProvider" android:exported="true"/> 
-7
source

Source: https://habr.com/ru/post/988755/


All Articles