Android Studio 0.4 在 APK META-INF/LICENSE.txt 中复制的重复文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20827885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt
提问by a.black13
After I have updated my Studio from 0.3.7 to 0.4.0, I can't compile my project. I found a solution on stackoverflow: Duplicate files copied (Android Studio 0.4.0)
在我将 Studio 从 0.3.7 更新到 0.4.0 后,我无法编译我的项目。我在 stackoverflow 上找到了一个解决方案:复制的文件重复(Android Studio 0.4.0)
I updated my project to gradle 0.7.+, but I don't know where I must put the next strings:
我将我的项目更新为 gradle 0.7.+,但我不知道我必须把下一个字符串放在哪里:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
My logcat: log
我的日志:日志
Execution failed for task ':Prog:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1: /home/scijoker/AndroidStudioProjects/ProgProject/Prog/libs/httpclient-4.1.1.jar
File 2: /home/scijoker/AndroidStudioProjects/ProgProject/Prog/libs/httpclient-4.1.1.jar
P.S. Develop in ubuntu 13.04
PS 在 ubuntu 13.04 中开发
回答by biniam
Putting the dependecies at the top and the packageOptions at the end worked for me.
将依赖项放在顶部,将 packageOptions 放在最后对我有用。
apply plugin: 'android'.
Here is my full build.gradle at the app folder.
这是我在 app 文件夹中的完整 build.gradle。
dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/apache-mime4j-0.6.jar')
compile files('libs/httpmime-4.0.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 10
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
EDIT: Almost all OS licence include the obligation to "include a copy of the licence" into your project. So this means, that you have to include a copy of all OS licences you use into you projects. By "excluding" them in gradle, you violate the licences.
编辑:几乎所有的操作系统许可证都包含在您的项目中“包含一份许可证副本”的义务。因此,这意味着您必须在项目中包含您使用的所有操作系统许可证的副本。通过在 gradle 中“排除”它们,您违反了许可证。
Excluding them from the project might not be the best option. Thank you R.S. for the info.
将他们排除在项目之外可能不是最好的选择。感谢 RS 提供的信息。
回答by R.S
Attention!! Possible OpenSource license violation.
注意力!!可能违反开源许可证。
With excluding license.txt files as proposed above you may violate some opensource licenses as it is a common point in opensource licences to agree to add it to your source. Better check your opensource licences.
如果按照上述建议排除 license.txt 文件,您可能会违反某些开源许可证,因为同意将其添加到源中是开源许可证中的一个常见点。最好检查一下你的开源许可证。
Update:Until there is a better solution, use
更新:直到有更好的解决方案,使用
packagingOptions {
pickFirst 'META-INF/license.txt'
}
like this you at least fulfill a part of the license obligation
像这样你至少履行了一部分许可义务
回答by shankey
just add
只需添加
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
in build.gradle
在 build.gradle 中
回答by AlfredZhong
You can fix it by adding the following code to project/app/build.gradle
:
您可以通过添加以下代码来修复它project/app/build.gradle
:
android {
// Fixed build error : Duplicate files copied in APK META-INF/xxx
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}
回答by Dhiral Pandya
I was facing the same problem as per new version of gradle, Below build.gradletext format work for me :
我遇到了与新版本 gradle 相同的问题,下面的build.gradle文本格式对我有用:
There are two Hymanson jars in my libs folder.
我的 libs 文件夹中有两个 Hymanson jar。
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.omtlab.myapplication"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'libs/Hymanson-core-asl-1.9.13.jar'
exclude 'libs/Hymanson-mapper-asl-1.9.13.jar'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/Hymanson-core-asl-1.9.13.jar')
compile files('libs/Hymanson-mapper-asl-1.9.13.jar')
}
回答by Jan Wilmans
Adding:
添加:
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
worked for me, biniam_Ethiopia's solution is probably the most fail-safe
为我工作,biniam_Ethiopia 的解决方案可能是最安全的
回答by Shreekant N
While inserting this code
插入此代码时
android{
packagingOptions{
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
MAKE SUREif in errorit is showing
请确认如果错误则显示
> Duplicate files copied in APK META-INF/LICENSE.txt
> 在 APK META-INF/ LICENSE.txt 中复制的重复文件
then add
然后加
android{
packagingOptions{
exclude 'META-INF/LICENSE.txt'
}
}
if in errorit is showing
如果错误显示
> Duplicate files copied in APK META-INF/LICENSE
> 在 APK META-INF/ LICENSE 中复制的重复文件
then add
然后加
android{
packagingOptions{
exclude 'META-INF/LICENSE'
}
}
if in errorit is showing
如果错误显示
> Duplicate files copied in APK META-INF/license.txt
> 在 APK META-INF/ license.txt 中复制的重复文件
then add
然后加
android{
packagingOptions{
exclude 'META-INF/license.txt'
}
}
In short text CASE and document FORMAT(.txt) is so important.
简而言之,CASE 和文档 FORMAT(.txt) 非常重要。
(this error exist in Android Studio 1.1.0 also)
(此错误也存在于 Android Studio 1.1.0 中)
回答by Suresh Sarak
This will help you solve the problem
这将帮助您解决问题
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
}
回答by Gajendra kumar
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
Add in build.gradle file and syn project
添加 build.gradle 文件和 syn 项目
回答by josedlujan
I just add 2:
我只添加2:
android{
packagingOptions{
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
}
}