在android studio中新增.jar檔案後,rebuild不報錯,執行報錯的解決
阿新 • • 發佈:2019-02-12
問題如題,一直以為是下載的jar有問題
報如下錯誤:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
解決方案:
位於Project 下,找到build.gradle 雙擊開啟,在android下面新增下面的內容,一般根據需要新增即可解決
packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1'}