首先我知道stackoverflow中已经存在这个问题,但是我无法解决它,尽管我尝试了不使用-injar、使用packagingOptions等建议
我知道这个版本会起作用,但我喜欢干净的构建。当我生成签名的 apk 时。项目清理后,我收到这些错误:
Warning:can't write resource [.readme] (Duplicate zip entry [classes.jar:.readme])
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [joda-time-2.8.1.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [joda-time-2.8.1.jar:META-INF/NOTICE.txt])
Run Code Online (Sandbox Code Playgroud)
有时代替 joda-time-2.8.1.jar 有 commons-collections4-4.0.jar (相同的 .readme, licence, notice)警告。
我尝试排除那些带有包装选项的人,但它不起作用。
这是我的模块的 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
defaultConfig {
applicationId 'com.example.myapp'
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName '0.1'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} …Run Code Online (Sandbox Code Playgroud)