58

I have

compile 'com.facebook.android:facebook-android-sdk:4.16.0'

My manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
...
    <application
            android:name=".MyApplication"
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AutoTheme"
            tools:replace="android:theme">

How to solve compile error:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute activity#com.facebook.FacebookActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar) from AndroidManifest.xml:69:13-72
    is also present at [com.facebook.android:facebook-android-sdk:4.16.0] AndroidManifest.xml:32:13-63 value=(@style/com_facebook_activity_theme).
    Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:66:9-70:47 to override.
NickUnuchek
  • 11,794
  • 12
  • 98
  • 138
  • It's showing error on activity tag. You need to remove style or provide tools:replace="android:theme" to your tag. Paste your whole manifest file here. – Ajith Pandian Sep 28 '16 at 18:38
  • 1
    It's some error in Facebook SDK v4.16 http://stackoverflow.com/a/39748440/983914 – oleynikd Sep 29 '16 at 19:12
  • [just follow this link.](http://stackoverflow.com/a/39748440/2017098) you'll find the answer.. – Ramesh Jaya Oct 04 '16 at 07:53
  • 1
    It seems like we have to either add `tools:replace="android:theme` or remove `android:theme="@android:style/Theme.Translucent.NoTitleBar"` from our AndroidManifest.xml file. Both ways worked for me. But which way is preferred? The current Facebook Android SDK version is 4.16.1 and the issue is that manifest merger failed due to [com.facebook.android:facebook-android;sdk:4.16.1] also having `android:theme="@android:style/Theme.Translucent.NoTitleBar"`. I believe that removing `android:theme="@android:style/Theme.Translucent.NoTitleBar"` is better. – kimbaudi Oct 14 '16 at 23:21

6 Answers6

105

1) Add xmlns:tools="http://schemas.android.com/tools" to <manifest> element at AndroidManifest

2) Add tools:replace="android:theme" to (facebook activity) <activity>

Here is my manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.company.product" xmlns:tools="http://schemas.android.com/tools">

    ...

    <application
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"
      android:name="MyApplication">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <intent-filter>
            ...
        </intent-filter>
      </activity>

      <!--FacebookActivity-->
      <activity
        tools:replace="android:theme"
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

        ...

      </application>

</manifest>
Pir Shukarullah Shah
  • 4,124
  • 2
  • 22
  • 42
  • 21
    I disagree. There is no need to add `xmlns:tools="http://schemas.android.com/tools"` to and add `tools:replace="android:theme"` to . Its better to just remove `android:theme="@android:style/Theme.Translucent.NoTitleBar"` from the xml tag since the latest Facebook SDK 4.16.1 already includes it. But either way works, so it doesn't matter from that standpoint. – kimbaudi Oct 14 '16 at 23:25
  • @kimbaudi Can you share where you found that information regarding Facebook SDK 4.16.1 including the `android:theme`? Facebook's [official docs](https://developers.facebook.com/docs/facebook-login/android#prerequisites) still recommend adding the `android:theme` attribute. – Srikar Reddy Oct 15 '16 at 17:16
  • Thanks its help me – Jatinkumar Patel Jul 07 '17 at 09:14
  • Thanks bro, it worked. I wonder what kind of genius develops an SDK that has conflicts for integrating the most basic use case (Login) – voghDev Feb 07 '18 at 07:46
7

Try this.

 <activity
                android:name="com.facebook.FacebookActivity"
                android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.Translucent.NoTitleBar" />

Replace to

  <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:theme="@style/com_facebook_activity_theme" />
Jignesh Goyani
  • 1,020
  • 9
  • 17
4

In your manifest, remove

android:theme="@android:style/Theme.Translucent.NoTitleBar"

in the FacebookActivity

Edit: Do you use firebase as well? If so, have a look here Android manifest merger with facebook and firebase libraries

Community
  • 1
  • 1
Al Wld
  • 869
  • 7
  • 19
3

You Just have to use the this in your Manifest for the FacebookActivity

  <activity android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            tools:replace="android:theme"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:label="@string/app_name" />
Jignesh Goyani
  • 1,020
  • 9
  • 17
Viking93
  • 269
  • 2
  • 3
  • 15
1

Remove this line @android:style/Theme.Translucent.NoTitleBar

This will solve your problem

(This way you will avoid manifest propery conflict)

Mercury
  • 7,430
  • 3
  • 42
  • 54
Manoj Behera
  • 2,736
  • 22
  • 13
0

In my case I changed the attribute android:theme="${appTheme}" (where manifestPlaceholders["appTheme"] = "@style/Theme2" in build.gradle) and got a compile error:

Execution failed for task ':app:processGoogleDebugManifest'. Manifest merger failed : Attribute application@theme value=(@style/Theme) from AndroidManifest.xml:23:9-42 is also present at AndroidManifest.xml:21:9-36 value=(@style/Theme2).
Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:15:5-92:19 to override.

I have 3 AndroidManifest files. Then I changed android:theme in all 3 files.

CoolMind
  • 26,736
  • 15
  • 188
  • 224