当将com.google.android.gms:play-services-auth:11.6.0和com.android.support.test.espresso:espresso-core:3.0.1作为依赖于安卓库模块时,我看到了一些兼容性问题
我得到了一个错误:
Execution failed for task ':mylibrary:transformResourcesWithMergeJavaResForDebugAndroidTest'.
More than one file was found with OS independent path 'protobuf.meta'当我尝试执行./gradlew :myLibrary:connectedAndroidTest时
下面是一个基本的build.gradle,我在上面复制了这个问题:
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'
}我不认为我可以排除这些文件的任何一个,因为内容是不同的。
发布于 2017-12-28 11:22:29
发生此问题是因为您使用两个包含相同文件的单独导入。您的问题是外部库可能有重复的内容,或者已经导入了两次,要解决这个问题,您应该将这些代码行放入build.gradle (Module: app)中。
增加以下几行:
android {
// [...]
packagingOptions {
pickFirst 'protobuf.meta'
}
}有时,也可以完全排除这个文件:exclude 'protobuf.meta'
在多模块项目中,由于仪器测试错误导致Android库无法构建,可能需要在build.gradle中包含此代码片段。
https://stackoverflow.com/questions/47298895
复制相似问题