Android Studio 報錯:More than one file was found with OS independent path 'META-INF/xxxxxx'的解決辦法
阿新 • • 發佈:2019-01-04
轉載:https://blog.csdn.net/realliuning/article/details/80010591
轉載:https://blog.csdn.net/wa172126691/article/details/84863171
今天在Android Studio中編譯工程的時候,遇見了一個奇怪的問題,報錯如下:
More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'
諸如:
More than one file was found with OS independent path ‘META-INF/
DEPENDENCIES’......
大概意思就是工程生成了不止一個META-INF/proguard/androidx-annotations.pro檔案,看起來是因為多個 jar 包裡包含了同樣的檔案(proguard/androidx-annotations.pro),導致打包時因為擔心相互覆蓋問題而提示出錯
在網上很容易就找到了解決方法,即在報該編譯錯誤的module的build.gradle中加入如下配置項,排除掉中間生成的proguard/androidx-annotations.pro檔案
packagingOptions { exclude 'META-INF/proguard/androidx-annotations.pro' exclude 'META-INF/DEPENDENCIES' .... }
新增後的部分build.gradle
檔案如下:
android { compileSdkVersion 28 defaultConfig { applicationId "com.demo.sportapp" minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } //這是新新增內容 packagingOptions { exclude 'META-INF/proguard/androidx-annotations.pro' exclude 'META-INF/DEPENDENCIES' } }