【问题标题】:Using Eclipe Collections with Android - build.gradle fails在 Android 中使用 Ecipe Collections - build.gradle 失败
【发布时间】:2017-12-15 17:52:04
【问题描述】:

对于我正在开发的 Android 项目,我需要* 使用 Eclipse Collections 框架。所以我根据他们的"get started"将它集成到我的build.gradle,并导入了需要的库。问题是,当我尝试在我的 Android 设备上运行该应用程序时,它会失败并显示以下消息:

错误:任务执行失败 ':app:transformResourcesWithMergeJavaResForDebug'。 发现多个文件具有独立于操作系统的路径“LICENSE-EDL-1.0.txt”

我在 Stackoverflow 上进行了一些谷歌搜索,并在 Stackoverflow 遇到了一些类似(尽管不相同)的问题,但没有一个建议的解决方案对我有用(其中大多数建议将 packagingOptions 添加到 build.gradle)。如果这很重要 - 我的应用使用 OpenCV4Android,我正在 Android Studio 中开发它。

另外,为了清楚起见,没有添加 Eclipse-Collections 一切都可以正常工作..

这是我的应用程序的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.example.android.coftest"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'org.eclipse.collections:eclipse-collections-api:9.0.0'
    compile 'org.eclipse.collections:eclipse-collections:9.0.0'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:26.+'
    compile 'com.android.support:support-vector-drawable:26.+'
    testCompile 'junit:junit:4.12'
    compile project(':openCVLibrary330')
}

* 这不是必须的,但它使我的代码更加简单和优雅,我真的很想拥有它。

【问题讨论】:

    标签: java android android-gradle-plugin build.gradle eclipse-collections


    【解决方案1】:

    将此添加到您的 gradle 中:

    packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/LICENSE-EDL-1.0.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
    

    }

    【讨论】:

    • 谢谢,但它不工作...... :(为了清楚起见,我将它添加到我的 gradle 的 android{} 部分
    • 替换这个: compile 'org.eclipse.collections:eclipse-collections-api:9.0.0' compile 'org.eclipse.collections:eclipse-collections:9.0.0' testCompile 'org.eclipse .collections:eclipse-collections-testutils:9.0.0' 编译 'org.eclipse.collections:eclipse-collections-forkjoin:9.0.0'
    • 您能否编辑您的答案(将您的评论添加到您的答案中)?很难确切地理解该怎么做......谢谢
    猜你喜欢
    • 2017-03-01
    • 2022-08-14
    • 1970-01-01
    • 2018-12-08
    • 1970-01-01
    • 2022-07-23
    • 2018-02-11
    • 2023-02-15
    • 2019-07-09
    相关资源
    最近更新 更多