【问题标题】:Android merged manifest errorAndroid合并清单错误
【发布时间】:2018-03-20 05:08:17
【问题描述】:

我收到以下错误。

合并错误:错误:属性活动# com.facebook.FacebookActivity@主题值 = (@android: style / Theme.Translucent.NoTitleBar) 来自 AndroidManifest.xml:50:13 - 72 也出现在 AndroidManifest.xml 中:32: 13 - 63 value = (@style / com_facebook_activity_theme). 建议:添加 'tools:replace="android:theme"' 到 AndroidManifest.xml 中的元素:45: 9 - 52: 16 覆盖.app 主清单(此文件),第 49 行

我的 AndroidManifest 文件

<?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="com.example.android.blogtry"

    >

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

    <application
        tools:replace="icon, label"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="Disaster Management"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

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

        <provider android:authorities="com.facebook.app.FacebookContentProvider21"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".PostActivity" />
        <activity android:name=".RegisterActivity" />
        <activity android:name=".LoginActivity" />
        <activity
            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
            android:theme="@style/Base.Theme.AppCompat" />
        <activity android:name=".BlogSingleActivity" />
        <activity android:name=".MyProfileActivity">
        </activity>

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

             />
        <activity
            android:name=".FbHomeActivity"
            android:label="@string/title_activity_home"
            android:theme="@style/AppTheme.NoActionBar"
            />
    </application>

</manifest>

我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.example.android.blogtry"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
        mavenCentral()
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    compile 'com.google.firebase:firebase-appindexing:11.0.2'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.google.android.gms:play-services-auth:11.0.2'
    compile 'com.google.firebase:firebase-database:11.0.2'
    compile 'com.google.firebase:firebase-storage:11.0.2'
    compile 'com.firebaseui:firebase-ui:2.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:design:24.1.1'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 只需要清理项目,然后在构建工具中重建项目。
  • @jigarsavaliya 我清理并重建了项目。仍然出现同样的错误。
  • @JRamesh 我按照这些步骤操作。仍然出现同样的错误。
  • @Ros 从 FacebookActivity 中删除工具:replace="android:theme"

标签: android


【解决方案1】:

删除tools:replace="android:theme 并删除android:theme="@android:style/Theme.Translucent.NoTitleBar"
来自facebookActivity(来自&lt;activity&gt; 标签) 在您的 AndroidManifest.xml 文件中,因为最新的 Facebook SDK 已经包含它。

【讨论】:

    【解决方案2】:

    尝试使用来自 Facebook SDK 的主题 style/com_facebook_activity_theme

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

    或者干脆删除主题行。喜欢:

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

    在这种情况下,主题将从 Facebook SDK 粘贴到清单中。

    但总的来说 tools:replace="android:theme" 应该可以工作。至少在我的项目中,它解决了 facebook 主题的问题。

    【讨论】:

      【解决方案3】:

      试试这个

      <application
              android:allowBackup="true"
              android:icon="@mipmap/ic_launcher"
              android:label="Disaster Management"
              android:supportsRtl="true"
              android:theme="@style/AppTheme"
              tools:replace="android:theme,icon,label">
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-06-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-01
        相关资源
        最近更新 更多