Android Facebook content provider authority

后端 未结 4 439
渐次进展
渐次进展 2020-12-31 01:14

I\'m developing an app with (at least) two flavors having different package names - therefore actually two different apps as far as the android system is concerned. The app

相关标签:
4条回答
  • One of the possible solutions I have found is the one described here

    http://gradlewhy.ghost.io/overcoming-install-failed-conflicting-provider/

    I am already using this for (debug/release variants) android.support.v4.content.FileProvider and as far I have tested also works for com.facebook.app.FacebookContentProvider.

    Just add into apps build.gradle

        debug {
            applicationIdSuffix '.debug'
            versionNameSuffix '-DEBUG'
    
            resValue "string", "fb_provider_id", "com.facebook.app.FacebookContentProvider{app_id_1}"
        }
    
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    
            resValue "string", "fb_provider_id", "com.facebook.app.FacebookContentProvider{app_id_2}"
        }
    

    and then in the AndroidManifest

    <provider android:authorities="@string/fb_provider_id"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>
    
    0 讨论(0)
  • 2020-12-31 01:56

    If your have one project and multiple flavors(means: multiple apps with minor tweaks) like me, you can

    1.create multiple facebook app (from https://developers.facebook.com/apps/)

    2.add codes for correspoding flavor

    3.add facebook_app_id string value in the corresponding flavor's folder.

    Example:

    app/build.gradle

    ...
    flavorDimensions "regular"
    
    productFlavors {
        flavour_name {
            dimension "regular"
            resValue "string", "authority", "com.facebook.app.FacebookContentProvider123456789"
        }
    

    app/src/main/AndroidManifest.xml

      <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>
    
    <provider android:authorities="@string/authority"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true" />
    

    app/src/flavour_name/res/values/string.xml

    <string name="facebook_app_id" translatable="false">123456789</string>
    
    0 讨论(0)
  • 2020-12-31 01:57

    I was able to solve this by having separate manifests for my debug and release flavors and in my debug flavor manifest, I added the snippet for the provider but set the exported value to false. In my release flavor manifest, I have the original provider snippet with exported set to true.

    After I did this, I no longer got the INSTALL_FAILED_CONFLICTING_PROVIDER error.

    <provider android:authorities="com.facebook.app.FacebookContentProvider{app id here}"
                android:name="com.facebook.FacebookContentProvider"
                android:exported="false"/>
    
    0 讨论(0)
  • 2020-12-31 02:03
    <provider android:authorities="com.facebook.app.FacebookContentProvider{app id here}"
                android:name="com.facebook.FacebookContentProvider"
                android:exported="false"/>
    

    exported can be "true"

    0 讨论(0)
提交回复
热议问题