5

I'm seeing some issues with compatibility between com.google.android.gms:play-services-auth:11.6.0 and com.android.support.test.espresso:espresso-core:3.0.1 when used as dependencies on an android library module

I'm getting this error:

Execution failed for task ':mylibrary:transformResourcesWithMergeJavaResForDebugAndroidTest'.   
More than one file was found with OS independent path 'protobuf.meta'

when I try to execute ./gradlew :myLibrary:connectedAndroidTest

Here's a barebones build.gradle that I've reproduced the problem on:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26



    defaultConfig {
        minSdkVersion 16
        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 {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services-auth:11.6.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

I don't think I can exclude either of these files as the contents is different.

6
  • add packagingOptions { exclude 'META-INF/DEPENDENCIES' } Nov 15, 2017 at 4:33
  • Gave me the same result
    – AJD
    Nov 15, 2017 at 5:09
  • same problem for 11.4.2? Nov 15, 2017 at 5:13
  • 11.4.2, 11.4.0, and 11.2.0 all fail. 11.0.0 surprisingly works...
    – AJD
    Nov 15, 2017 at 5:32
  • 1
    Raised here: issuetracker.google.com/issues/69333598
    – AJD
    Nov 15, 2017 at 5:37

1 Answer 1

16

This issue occurred because you use two separate imports containing the same file. Your issue is with an external library that may have duplicate contents or was imported twice, to solve this You should put these lines of code inside build.gradle (Module: app).

Add the following lines:

android {
    // [...]
    packagingOptions {
        pickFirst 'protobuf.meta'
    }
}

Sometimes, it is also possible to completely exclude this file: exclude 'protobuf.meta'

In case of multi-module projects, Android libraries failing to build due to this error on instrumentation tests, might need to include this snippet inside build.gradle.

4
  • Where? Why? Please provide more info.
    – Randy
    Mar 6, 2018 at 1:39
  • 1
    This issue occurred because you use two separate imports containing the same file. Your issue is with an external library that may have duplicate contents or was imported twice, to solve this You should put these lines of code inside build.gradle(Module: app) .
    – T.Binyam
    Mar 7, 2018 at 7:30
  • Thanks for clarifying. I can confirm that this works. Please update the answer and I’ll up vote it.
    – Randy
    Mar 11, 2018 at 5:22
  • Thanks you so much, i was stuck for long time, it worked. Jun 23, 2020 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.