如何解决添加依赖项时出现的错误(清单合并)

时间:2018-06-28 14:19:28

标签: android android-studio github

我正在我的项目中尝试使用 Sweet Alert对话框here),但是我遇到了问题。 我正在关注README.md文件,但我不知道将以下内容放在android studio中的位置:

MAVEN

<dependency>
    <groupId>cn.pedant.sweetalert</groupId>
    <artifactId>library</artifactId>
    <version>1.3</version>
    <type>aar</type>
</dependency>

我已经成功地修改了build.gradle项目级别,但是我不知道该怎么做。

我的模块gradle文件是:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.vogella.android.service.receiver.myapplication"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
}
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.android.support:support-v4:27.1.1'
    compile 'com.android.support:design:27.1.1'

    //Sweet alert dialog
    compile 'cn.pedant.sweetalert:library:1.3'


}

项目级gradle文件:

buildscript {

repositories {
    google()
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'


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

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

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

这就是我得到的错误:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@icon value= 
(@mipmap/ic_launcher) from AndroidManifest.xml:7:9-43
is also present at [com.pnikosis:materialish-progress:1.0] 
AndroidManifest.xml:13:9-45 value=(@drawable/ic_launcher).
Suggestion: add 'tools:replace="android:icon"' to <application> element at 
AndroidManifest.xml:5:5-19:19 to override.

2 个答案:

答案 0 :(得分:1)

如果您仔细观察,这是关于maven存储库的。您应该使用gradle.,它将起作用。进入模块gradle文件,并在dependency标记中写dependency,然后写reporitories并将mavenCentral放入其中。

  repositories {
    mavenCentral()
}

dependencies {
    implementation 'cn.pedant.sweetalert:library:1.3'
}

通过查看日志,问题出在清单合并中:

 xmlns:app="http://schemas.android.com/tools"
 app:replace="android:icon

答案 1 :(得分:0)

将此添加到您的应用级gradle,然后再次同步。

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}