如何解决Facebook的tools:replace=“android:theme”?

vshtjzan  于 2023-05-21  发布在  Android
关注(0)|答案(6)|浏览(196)

我有

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=".MyApplication"
            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.
x33g5p2x

x33g5p2x1#

1)将xmlns:tools="http://schemas.android.com/tools"添加到AndroidManifest中的<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>
4xy9mtcn

4xy9mtcn2#

试试这个

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

替换为

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

h7appiyu3#

在你的清单中,删除

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

在Facebook活动

**编辑:**你也用firebase吗?如果是,请看这里Android manifest merger with facebook and firebase libraries

zf9nrax1

zf9nrax14#

你只需要在你的清单中使用this就可以了

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

xxls0lw85#

删除此行@android:style/Theme.Translucent.NoTitleBar
这会解决你的问题
(This避免明显的属性冲突)

8nuwlpux

8nuwlpux6#

在我的例子中,我改变了属性android:theme="${appTheme}"(其中manifestPlaceholders["appTheme"] = "@style/Theme2"build.gradle中),得到了一个编译错误:
任务“:app:processGoogleDebugManifest”执行失败。清单合并失败:AndroidManifest.xml:23:9-42中的属性application@theme value=(@style/Theme)也存在于AndroidManifest.xml:21:9-36 value=(@style/Theme 2)中。
建议:在AndroidManifest.xml:15:5-92:19的元素中添加'tools:replace=“android:theme”'来覆盖。
我有3个AndroidManifest文件。然后我在所有3个文件中更改了android:theme

相关问题