INSTALL_FAILED_CONFLICTING_PROVIDER with Facebook SDK when I build multiple productFlavors

核能气质少年 提交于 2019-12-04 04:59:25

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"]
    }
}

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 to your App id

<provider android:authorities="com.facebook.app.FacebookContentProvider{app id here}"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!