首页 > 解决方案 > 如何修复“在Android中发现多个文件与操作系统无关路径'META-INF/DEPENDENCIES'错误

问题描述

我正在迁移到 google drive api v3 并根据此示例更新依赖项,如下所示:

implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
implementation('com.google.api-client:google-api-client-android:1.26.0') {
    exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
    exclude group: 'org.apache.httpcomponents'
}

但我面临这个错误:

发现多个文件的操作系统独立路径为“META-INF/DEPENDENCIES”

并且无法运行该应用程序

标签: android-studioandroid-gradle-plugingoogle-drive-api

解决方案


使用packagingOptions pickFirstexclude;认为应该保存以排除它:

android {
    packagingOptions {
        // pickFirst "META-INF/DEPENDENCIES"
        exclude "META-INF/DEPENDENCIES"
    }
}

1.25.0和之间似乎也存在版本不匹配1.26.0。当前版本是:

implementation "com.google.apis:google-api-services-drive:v3-rev173-1.25.0"

其他人可能也需要 version 1.25.0


推荐阅读