Facebook provider unconfigured. Make sure to add a

2019-07-22 00:35发布

I'm using Firebase UI Sign In and trying to implement Facebook sign in into my android app. When launching the firebase ui activity I get:

"java.lang.IllegalStateException: Facebook provider unconfigured. Make sure to add a facebook_application_id string"

In my string resources I have added it, this is how it looks: By the way in the firebase docs the string names are different from the ones in the facebook docs, this is how they look in the facebook docs or also called quickstart:

`<string name="facebook_app_id" translatable="false">SOMECODE</string>
<string name="fb_login_protocol_scheme" 
translatable="false">SOMECODE</string>`

This is how it looks in the firebase docs:

 <string name="facebook_application_id" 
 translatable="false">YOUR_APP_ID</string>

<string name="facebook_login_protocol_scheme" 
translatable="false">fbYOUR_APP_ID</string>

I was also having some merging problem and fixed it by adding tools:replace="android:value" to the metadata and yes everything was added inside the application tags

<meta-data android:name="com.facebook.sdk.ApplicationId"
        tools:replace="android:value"
        android:value="@string/facebook_app_id"
        />

    <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
            "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>

I don't know what's causing these problems but I think it has something to do with the string names, if anyone can help me please I will immensely appreciate it. Thank you!

3条回答
女痞
2楼-- · 2019-07-22 00:42

Use this is AndroidManifest.xml

<meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/FACEBOOK_FB_APP_ID" />

and in strings.xml

    <string name="FACEBOOK_FB_APP_ID">{application id}</string>
查看更多
Ridiculous、
3楼-- · 2019-07-22 00:57

Add Facebook Provider in Manifest as mentioned here.

Append your app id to the end of the authorities value. For example if your Facebook app id is 1234, the declaration looks like:

<provider android:authorities="com.facebook.app.FacebookContentProvider1234"
          android:name="com.facebook.FacebookContentProvider"
          android:exported="true" />
查看更多
Explosion°爆炸
4楼-- · 2019-07-22 01:06

Alright I was thinking that the strings provided by firebase and the ones provided by facebook where the same and I had to have only a pair of them, the truth is that they are different and add the ones provided by firebase and facebook to your string resources, that will solve the problem.

查看更多
登录 后发表回答