&引用;复制在APK-META-INF/license.txt中的lib文件;Android Studio中的错误
我在项目中使用了以下2个库 1.spring-core-3.1.0.RELEASE.jar 2.spring-web-3.1.0.RELEASE.jar 但android studio正在考虑为上述库复制条目,并在打包时给出错误&引用;复制在APK-META-INF/license.txt中的lib文件;Android Studio中的错误,android,android-studio,Android,Android Studio,我在项目中使用了以下2个库 1.spring-core-3.1.0.RELEASE.jar 2.spring-web-3.1.0.RELEASE.jar 但android studio正在考虑为上述库复制条目,并在打包时给出错误 有人面临类似的问题吗 请建议解决此错误的一些方法。转到您的build.gradle文件并添加以下行: packagingOptions { exclude 'META-INF/license.txt' } 在我的案例中,我必须添加如下内容: apply
有人面临类似的问题吗
请建议解决此错误的一些方法。转到您的
build.gradle
文件并添加以下行:
packagingOptions {
exclude 'META-INF/license.txt'
}
在我的案例中,我必须添加如下内容:
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/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.google.code.gson:gson:2.2.4'
compile "org.apache.httpcomponents:httpcore:4.4.1"
compile "org.apache.httpcomponents:httpmime:4.3.6"
}
注意:
我有最简单的txt文件解决方案。如果删除依赖项中的所有txt文件 仅添加此块
packagingOptions {
exclude '**/*.txt'
}
重要提示:排除文件时,请注意它区分大小写
我将此添加到gradle中,但它不起作用:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
我发现了一个错误:
Duplicate files copied in APK META-INF/notice.txt
因此,修复方法是添加META-INF/notice.txt:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
}
我必须同时添加
排除'META-INF/LICENSE.txt'排除'META-INF/NOTICE.txt'
您也可以排除'META-INF/*'
排除所有文件。@Mohammad Arman关于禁止删除许可文件/通知的许可证怎么办?可能是
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
}