如何解决Facebook工具:replace =“android:theme”?

我有

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

我的清单:

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

如何解决编译错误:

 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. 

Solutions Collecting From Web of "如何解决Facebook工具:replace =“android:theme”?"

1)在AndroidManifest中将xmlns:tools="http://schemas.android.com/tools"<manifest>元素

2)添加tools:replace="android:theme" (facebook活动) <activity>

这是我的清单文件

 <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> 

尝试这个。

  <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为

  <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" /> 

在你的清单中,删除

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

在FacebookActivity

编辑:你也使用firebase? 如果是这样,看看这里的Android清单合并与Facebook和Firebase库

你只需要在你的Manifest中使用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" /> 

删除这行@android:style / Theme.Translucent.NoTitleBar

这将解决你的问题