【问题标题】:Manifest Merger Failed - support:appcompat-v7:26.+清单合并失败 - 支持:appcompat-v7:26.+
【发布时间】:2017-07-30 08:04:18
【问题描述】:

错误:任务 ':app:processDebugManifest' 执行失败。 清单合并失败:来自 [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 的属性 meta-data#android.support.VERSION@value value=(25.3.1) 也存在于 [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1)。 建议:将 'tools:replace="android:value"' 添加到 AndroidManifest.xml:22:5-24:34 的元素以覆盖。

我正在尝试制作一个目标 SDK 为 26 的应用程序。 该应用程序需要 Facebook SDK(根据 Facebook SDK Versions 的最新版本 4.25.0。

Volley 是 1.0.0 版 (Android Volley Dev Page)

我只能从错误中猜测其中一些 SDK 共享库,但一个将不同的版本加载到另一个...所以我需要在我的 Gradle 文件中添加某种形式的“加载这个而不是这个”命令?还是我只是错过了什么?

上述错误发生在我的 Gradle 构建文件中,如下所示。

项目 Gradle 构建:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用 gradle 构建:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.johnny.fibre"
        minSdkVersion 18
        targetSdkVersion 26

        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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.facebook.android:facebook-android-sdk:4.25.0'
    compile 'com.android.support:appcompat-v7:26.+'
    //compile "com.android.support:support-core-utils:25.+"
    compile 'com.android.volley:volley:1.0.0'
    //compile 'com.android.support:support-v4:26.0.0'
    testCompile 'junit:junit:4.12'
}

我的 AndroidManifest.xml

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">

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

        <activity android:name=".Home">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_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">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>

    </application>

</manifest>

感谢您的帮助!我一直在评论和更改 SDK 版本和各种...

【问题讨论】:

    标签: android facebook gradle sdk manifest


    【解决方案1】:

    我通过进一步浏览论坛解决了这个问题:

    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.android.support:cardview-v7:26.0.0-alpha1'
        compile 'com.android.support:customtabs:26.0.0-alpha1'
        compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'junit:junit:4.12'
        compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    
    
    }
    

    依赖关系

    com.android.support:cardview-v7:26.0.0-alpha1
    compile 'com.android.support:customtabs:26.0.0-alpha1'
    

    添加似乎可以解决问题。

    【讨论】:

      【解决方案2】:

      facebook sdk 在其依赖项中使用'com.android.support:appcompat-v7:25.3.1''com.android.support:support-v4:25.3.1'

      如果您来自 facebook 依赖项 exclude support-v4,则此错误将得到解决,如下所示:

      compile (‘com.facebook.android:facebook-android-sdk:4.25.0’){
          exclude group: 'com.android.support', module: 'support-annotations'
      }
      

      或将其从您的依赖项中的compile 'com.android.support:appcompat-v7:26.+' 中排除。

      【讨论】:

      • 感谢您的帮助。我重新排序了依赖项,并在顶部添加了几个“较新”的依赖项,它们似乎已经覆盖了问题。
      【解决方案3】:

      排除库中的依赖是麻烦制造者:-) 让我们看一个例子:

      implementation("com.jakewharton.rxbinding2:rxbinding:1.0.2") {
        exclude group: 'com.android.support'
      }
      

      您也可以更具体地添加要排除的模块:

      exclude group: 'com.android.support', module: 'appcompat-v7' 
      

      【讨论】:

        【解决方案4】:

        我已经解决了这个问题,更改 app 文件夹中 build.gradle 中的以下编译文件。现在我正在使用这些编译文件。

        compile 'com.android.support:cardview-v7:26.+'
        compile 'com.android.support:customtabs:26.+'
        compile 'com.android.support:appcompat-v7:26.+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.android.support:recyclerview-v7:26.+'
        

        在更改之前我正在使用这些文件

        compile 'com.android.support:cardview-v7:26.0.0-alpha1'
        compile 'com.android.support:customtabs:26.0.0-alpha1'
        compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
        

        只需更改编译文件的版本。使用“26.+”而不是“26.0.0-alpha1”

        谢谢

        【讨论】:

          猜你喜欢
          • 2019-12-26
          • 2019-08-29
          • 2020-01-26
          • 2015-10-04
          • 2014-12-31
          • 1970-01-01
          • 2018-05-25
          • 2018-03-11
          • 2019-11-17
          相关资源
          最近更新 更多