Gradle: Error: more than one library with package name 'com.google.android.gms'

后端 未结 6 1528
予麋鹿
予麋鹿 2020-12-08 07:02

What does this error message mean? I don\'t have duplicated packages in my project

Error:Execution failed for task \':SimpleReader:processDebugResourc

6条回答
  •  粉色の甜心
    2020-12-08 07:47

    I had confused with this problem for a long time.My issue is little different with the question though same error log. I want my sublib's buildtype same with my application's buildtype. So I assigned the buildtype for sublib as the document tells me. [Gradle Plugin User Guide][1]

    This the error I got.

    processing flavorCustomResource

    Error: more than one library with com.xxx.libCommon

    This is my structure. lib1 and lib2 are independent of each other.

    app

    -> lib1 -> libCommon

    -> lib2 -> libCommon

    I got the error only when I build my custom buildtype.However, The release version was Ok.

    More details. some parts of my build.gradle

    app:

    android {
        buildTypes {
            release{}
            custom{}
        }
    }
    configurations {
        flavorReleaseCompile
        flavorCustomCompile
    }
    dependencies{
        compile project(':lib1')
        flavorReleaseCompile project(path: ':lib2', configuration: ':release')
        flavorCustomCompile project(path: ':lib2', configuration: ':custom')
    }
    

    lib1:

    android {
        publishNonDefault true
        buildTypes {
            release{}
            custom{}
        }
    }
    
    dependencies{
        releaseCompile project(path: ':libCommon', configuration: ':release')
        customCompile project(path: ':libCommon', configuration: ':custom')
    }
    

    lib2

    dependencies {
        compile project(':libCommon')
    }
    

    Solution: configure the lib2 as lib1. the problem will be solved.

    lib2:

    android {
        publishNonDefault true
        buildTypes {
            release{}
            custom{}
        }
    }
    
    dependencies{
        releaseCompile project(path: ':libCommon', configuration: ':release')
        customCompile project(path: ':libCommon', configuration: ':custom')
    }
    

    Reason

    The problem is something about Library Publication

    The default publish is release. if lib2 is not configured, it will use the default publish libCommon(release version) which is different from lib1 -> libCommon(custom version) assigned by lib1's build.gradle.This comes the error.

    I wish my post will help someone struggle with the same issue or give some hint to him/her.

提交回复
热议问题