当我添加 compile group: 'com.google.cloud', name: 'google-cloud-storage', version: '0.8.0-beta'
时,它在我运行应用程序时显示错误
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForProductionDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/INDEX.LIST
File1: /.gradle/caches/modules-2/files-2.1/com.google.cloud/google-cloud-storage/0.8.0-beta/92c10417dd9ef400564414c243eecdd0a7f51963/google-cloud-storage-0.8.0-beta.jar
File2: /.gradle/caches/modules-2/files-2.1/com.google.cloud/google-cloud-core/0.8.0/5fe7f10ded15149a5fc633d98adbacf11b00907f/google-cloud-core-0.8.0.jar
我添加了排除META INF文件
packagingOptions {exclude'META-INF / MANIFEST.MF'排除'META-INF / ASL2.0'排除'META-INF / DEPENDENCIES.txt'排除'META-INF / LICENSE.txt'排除'META-INF / NOTICE . txt'排除'META-INF / NOTICE'排除'META-INF / LICENSE'排除'META-INF / DEPENDENCIES'排除'META-INF / notice.txt'排除'META-INF / license.txt'排除'META- INF / dependencies.txt'排除'META-INF / LGPL2.1'}
试过https://github.com/GoogleCloudPlatform/google-cloud-java#quickstart,同样的问题
有解决方案吗
2 回答
Solution
从maven下载jar文件并将它们添加到lib文件夹
google-api-services-storage-v1-rev92-1.22.0.jar
google-cloud-0.8.0.jar
google-cloud-core-0.8.0.jar
google-cloud-storage-0.8.0-beta.jar
并在app build.gradle中排除重复的文件
您可能会在 Cloud 存储上遇到重复项的出现 . 如果发生这种情况,您可以使用该服务来识别和删除重复项 . http://alternativeto.net/software/duplicate-file-finder-and-remover/