我已经为这个问题找到了许多答案,例如: Error :: duplicate files during packaging of APK Gradle sync fails after adding Firebase dependency: duplicate files during packaging of APK
但是在添加packagingOptions后我仍然收到重复的文件错误。
我正在使用库,这是我的app build gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.mcxiaoke.volley:library:1.0.14'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3')
}
修改
在我的示例中添加packagingOption,我将我的库添加为依赖项解决了问题,任何人都可以告诉我为什么必须将它添加到我的示例build.gradle中?或者有没有办法从样本中删除。