More than one file was found with OS independent path ‘META-INF/DEPENDENCIES’.
出现这个问题是因为引入了多个第三方库,而第三方库中拥有很多重名的文件,所以会报这种错误
packagingOptions {
exclude 'META-INF/****
}
exclude ‘META-INF/****:后面是什么错误就写什么,例如我的错误是’META-INF/DEPENDENCIES’,所以要写成下面这样:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
那么具体位置在哪里呢:
选取自己出错的build.grade,然后修改:
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
//注意,只添加这条语句即可
//*************************************
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
//*************************************
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
google()
mavenCentral()
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation files('libs\\okhttp-3.2.0.jar')
implementation files('libs\\httpmime-4.0.1.jar')
implementation files('libs\\httpcore-nio-4.0.1.jar')
implementation files('libs\\httpcore-4.0.1.jar')
implementation files('libs\\httpclient-4.0.1.jar')
implementation files('libs\\commons-logging-1.1.jar')
implementation files('libs\\commons-lang-2.5.jar')
implementation files('libs\\okio-1.12.0.jar')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
}