Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INSTALL_FAILED_CONFLICTING_PROVIDER with Facebook SDK when I build multiple productFlavors

I'm building an Android app with multiple productFlavors, and using Facebook SDK v4.1 for login and sharing contents. The problem is that when I try to install an app on a device which already has the same app installed (but different flavor), it raises an error. It doesn't allow me to install the second app unless I uninstall the existing one.

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

According to this document, the android:authorities should be unique and I should have multiple auths to accomplish what I want to do. However, I can't have multiple Facebook AppIds, and was wondering if there's better way to solve this problem. Thanks in advance to anyone who can help me!

like image 460
Nari Kim Shin Avatar asked Jun 09 '15 05:06

Nari Kim Shin


People also ask

What is FacebookContentProvider?

FacebookContentProvider. FacebookContentProvider. Implements a. ContentProvider that can be used to provide binary attachments (e.g., images) to calls made via FacebookDialog.


1 Answers

Try below :

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"]
    }
}
like image 178
Jaewon Kim Avatar answered Sep 20 '22 19:09

Jaewon Kim