firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.63k stars 1.84k forks source link

Conflict with Facebook App ID in Manifest #1026

Closed troy21688 closed 6 years ago

troy21688 commented 6 years ago

I recently updated to compile "com.firebaseui:firebase-ui:3.0.0"

and received the following error:

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute meta-data#com.facebook.sdk.ApplicationId@value value=(@string/facebook_app_id) from AndroidManifest.xml:29:13-52 is also present at [com.firebaseui:firebase-ui-auth:3.0.0] AndroidManifest.xml:21:13-60 value=(@string/facebook_application_id). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:27:9-29:55 to override.

I am not sure why I am being prompted to change the of my Facebook class where I currently have my Facebook App ID.

samtstern commented 6 years ago

@troy21688 could you try removing the Facebook ID from your AndroidManifest.xml and then adding it in your string resources:

<resources>
    <!-- ... -->
    <string name="facebook_application_id" translatable="false">APP_ID</string>

    <!-- OPTIONAL Facebook Application ID, prefixed by 'fb'.  Enables Chrome Custom tabs. -->
    <string name="facebook_login_protocol_scheme" translatable="false">fbAPP_ID</string>
</resources>
troy21688 commented 6 years ago

I am actually calling it from the String resources, it is not hardcoded if that's what you are referring to.

On Tue, Nov 21, 2017 at 1:52 PM, Sam Stern notifications@github.com wrote:

@troy21688 https://github.com/troy21688 could you try removing the Facebook ID from your AndroidManifest.xml and then adding it in your string resources:

APP_ID fbAPP_ID

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/FirebaseUI-Android/issues/1026#issuecomment-346141670, or mute the thread https://github.com/notifications/unsubscribe-auth/APuF-P60HvkOWo6gXn_fbSHWPJY87Iufks5s4yoFgaJpZM4QlNVe .

-- Troy Chuinard, CPA

samtstern commented 6 years ago

Can you show your AndroidManifest.xml here?

troy21688 commented 6 years ago

`<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="xxxxxxx">

<uses-permission android:name="android.permission.INTERNET" />

<application
    android:name="android.support.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:icon="@drawable/xxxxxxx"
    android:label="@string/xxxxxxx"
    android:theme="@style/AppTheme.NoActionBar"> <!-- ADD THIS LINE -->

    <activity
        android:name=".SignupActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustPan" />
    <activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        tools:replace="android:theme" />

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />
    <meta-data
        android:name="com.firebase.ui.GoogleClientId"
        android:value="@string/google_client_id" />
    <meta-data
        android:name="com.firebase.ui.TwitterKey"
        android:value="@string/twitter_app_key" />
    <meta-data
        android:name="com.firebase.ui.TwitterSecret"
        android:value="@string/twitter_app_secret" />

    <activity
        android:name=".PollHostActivity"
        android:label="@string/title_activity_poll"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustPan" />
    <activity
        android:name=".LoadingActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".HomeActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".CreateActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".NewImageActivity"
        android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>

        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable" />
    </activity>
    <activity
        android:name=".ProfileActivity"
        android:label="@string/title_activity_profile"
        android:theme="@style/AppTheme.NoActionBar"></activity>
</application>

`

samtstern commented 6 years ago

@troy21688 apologies for the delayed response, Thanksgiving happened and I lost track of some things.

You can see in the AndroidManifest.xml for the auth module we already have the com.facebook.sdk.ApplicationId metadata entry:

https://github.com/firebase/FirebaseUI-Android/blob/a7f2373d9e8ae547bb114b38001e0fcd0e65eb0e/auth/src/main/AndroidManifest.xml#L15

So there's no need to put it in your AndroidManifest.xml as well, it will be merged in by the Android manifest merger. If you want to customize the value of this meta-data entry, just change the value of @string/facebook_application_id and things will work as expected.

samtstern commented 6 years ago

@troy21688 is this still an issue for you?

shyamwebb commented 6 years ago

Hi,

I am facing the same issue., I cant use both Facebook and Firebase UI together. Can anyone help me pls?

SUPERCILEX commented 6 years ago

@samtstern I think this issue can be closed since the fix is simply to remove the extra meta-data.

samtstern commented 6 years ago

@SUPERCILEX :+1:

AKKaung commented 6 years ago

I'm also facing this error too, can somebody explain that?

MihailButnaru commented 6 years ago

To fix the problem just remove the:

<meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
xengvang1984 commented 6 years ago

Removing the application id from meta-data did not resolve this for me. The problem for me was that Firebase UI had a value entry for facebook id. If you use firebase UI, it uses the firebase values and that is where the conflict is. The default value for the facebook id for the Firebase UI package is "CHANGE_ME". Same with the facebook protocol value. I had to find the name of those values (facebook_application_id, facebook_login_protocol_scheme) and create both of those in my Strings.xml with my correct values. If you do not use firebase UI then I don't think this fix may work for you. Here is my code on how I fixed it. Hope this helps.

AndroidManifest.xml File `<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_application_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">

    </activity>`

Strings.xml file: `

YOUR_FB_ID
<!-- Facebook Application ID, prefixed by 'fb'. Enables Chrome Custom tabs. -->
<string name="facebook_login_protocol_scheme" translatable="false">YOUR_FB_PROTOCOL_ID</string>

`

pedrohdsl commented 5 years ago

Just add tools:replace="android:value" on AndroidManifest like this:

<!-- Facebook API Key -->
    <meta-data
        tools:replace="android:value"
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />
nhoefer2 commented 5 years ago

It looks like firebase is looking for the string "facebook_application_id" but I think most are named "facebook_app_id" instead. I added both of these to my strings and it fixed the issue:

<string name="facebook_app_id">APP_ID</string>
<string name="facebook_application_id">APP_ID</string>
luongthe7749 commented 4 years ago

hi bro ! a also have that error. so my slove is just change the name : "facebook_app_id" to -> "facebook_application_id" in string file , so it work. hope this help

YohannBe commented 3 years ago

nhoefer2 you were right, it's all we had to do, thank you !!

stanleybenz commented 1 year ago

hi bro ! I also have that error. so my slove is just to change the name : "facebook_app_id" to -> "facebook_application_id" in string file , so it work. hope this help

Great it worked like magic, but I had to replace all facebook_com_id to facebook_application_id in all the files in the project using replace in file feature on Android Studio