本文介绍了重复输入错误-依赖关系和项目模块冲突-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先.以下是我遇到的错误.

First of all. Below is the error that I am getting.

现在,我正在做的事情如下....

Now, What I am doing is like below....

我正在集成IBM的语音转文本服务.我已经创建了一个演示这里!

I am integrating Speech To Text service of IBM. I have founded a demo HERE!

我还使用了另外两个IBM服务,分别为 Personality Insights Cloudant数据库.

I am also using another two Services of IBM named Personality Insights and Cloudant Database.

我已经成功集成了语音转文字示例.但是,当我集成个性化见解 Cloudant数据库时,它给我带来了错误.

I have successfully integrated Speech To Text example. But When I integrate Personality Insights and Cloudant Database it gives me above error.

我已识别的内容:

  • 在STT演示中,有一个名为 speech-android-wrapper 的模块.
  • 我已将其包含到我的应用程序中,并在* build.gradle **文件中添加了一行,如compile project(':speech-android-wrapper').
  • 对于 Cloudant数据库服务,我具有类似compile group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release'的依赖项.
  • 当我评论 Cloudant数据库依赖性时.它不会给我以上错误.
  • 所以,在某些情况下,这两个依赖关系是冲突的.
  • In STT demo there is a module called speech-android-wrapper.
  • Which I have included to my app and added a line to *build.gradle** file like compile project(':speech-android-wrapper').
  • For Cloudant Database service I have dependency like compile group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release'.
  • When I comment Cloudant Database dependency. It won't give me above error.
  • So, Some where these two dependencies are being conflicts.

下面是我的应用程序的build.gradle文件.

Below is my Application's build.gradle file.

build.gradle

build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }

    defaultConfig {
        multiDexEnabled true
        applicationId "com.stt_int.android01.sttdemofour"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    // ... other project repositories
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile project(':speech-android-wrapper')
    compile 'com.facebook.android:facebook-android-sdk:4.7.+'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    /*compile('com.mopub:mopub-sdk:4.3.0@aar') {
        transitive = true
    }*/
    compile('com.twitter.sdk.android:twitter:1.13.0@aar') {
        transitive = true;
    }
    compile 'com.ibm.watson.developer_cloud:java-sdk:2.6.0'
    compile group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release'
}

下面是 speech-android-wrapper 模块的build.gradle文件

Below is speech-android-wrapper module's build.gradle file

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion '22.0.1'
    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 16
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile files('libs/java_websocket.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/jna.jar')
}

我尝试使用以下代码排除 ByteOrderMark.class 类,但无法获得期望的结果.

I have try to exclude ByteOrderMark.class class using below code but I can not get desire outcome.

android { packagingOptions { exclude 'org/apache/commons/io/ByteOrderMark.class' }}

android { packagingOptions { exclude 'org/apache/commons/io/ByteOrderMark.class' }}

任何帮助都会非常非常.谢谢!

更新1:日期:2016年3月28日

我从 @Nikolay Shmyrev 建议的两个链接中尝试了以下操作,但是没有一个链接对我有用.

I have tried like below from two links suggested by @Nikolay Shmyrev but none of links worked for me.

从第一个链接开始.
dependencies { compile files('libs/java_websocket.jar') //compile files('libs/commons-io-2.4.jar') compile('commons-io:commons-io:2.4') { exclude group: 'org.apache', module: 'commons-io' } compile files('libs/jna.jar')}

From 1st link.
dependencies { compile files('libs/java_websocket.jar') //compile files('libs/commons-io-2.4.jar') compile('commons-io:commons-io:2.4') { exclude group: 'org.apache', module: 'commons-io' } compile files('libs/jna.jar')}

从第二个链接开始.
dependencies { compile files('libs/java_websocket.jar') //compile files('libs/commons-io-2.4.jar') compile('commons-io:commons-io:2.4') { exclude group: 'org.apache.commons.io' } compile files('libs/jna.jar')}
我已经从 speech-android-wrapper 模块的libs文件夹中删除了commons-io-2.4.jar文件.

From 2nd link.
dependencies { compile files('libs/java_websocket.jar') //compile files('libs/commons-io-2.4.jar') compile('commons-io:commons-io:2.4') { exclude group: 'org.apache.commons.io' } compile files('libs/jna.jar')}
I have removed commons-io-2.4.jar file from libs folder of speech-android-wrapper module.

更新2:日期:2016年3月29日

我也在下面尝试过.

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.0' compile project(':speech-android-wrapper') compile 'com.facebook.android:facebook-android-sdk:4.7.+' compile 'com.mcxiaoke.volley:library:1.0.19' /*compile('com.mopub:mopub-sdk:4.3.0@aar') { transitive = true }*/ compile('com.twitter.sdk.android:twitter:1.13.0@aar') { transitive = true; } compile 'com.ibm.watson.developer_cloud:java-sdk:2.6.0' compile(group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release') { exclude group: 'org.apache', module: 'commons-io' }}

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.0' compile project(':speech-android-wrapper') compile 'com.facebook.android:facebook-android-sdk:4.7.+' compile 'com.mcxiaoke.volley:library:1.0.19' /*compile('com.mopub:mopub-sdk:4.3.0@aar') { transitive = true }*/ compile('com.twitter.sdk.android:twitter:1.13.0@aar') { transitive = true; } compile 'com.ibm.watson.developer_cloud:java-sdk:2.6.0' compile(group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release') { exclude group: 'org.apache', module: 'commons-io' }}

也在下面.

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.0' compile project(':speech-android-wrapper') compile 'com.facebook.android:facebook-android-sdk:4.7.+' compile 'com.mcxiaoke.volley:library:1.0.19' /*compile('com.mopub:mopub-sdk:4.3.0@aar') { transitive = true }*/ compile('com.twitter.sdk.android:twitter:1.13.0@aar') { transitive = true; } compile 'com.ibm.watson.developer_cloud:java-sdk:2.6.0' compile(group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release') { exclude group: 'org.apache.commons.io' }}

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.0' compile project(':speech-android-wrapper') compile 'com.facebook.android:facebook-android-sdk:4.7.+' compile 'com.mcxiaoke.volley:library:1.0.19' /*compile('com.mopub:mopub-sdk:4.3.0@aar') { transitive = true }*/ compile('com.twitter.sdk.android:twitter:1.13.0@aar') { transitive = true; } compile 'com.ibm.watson.developer_cloud:java-sdk:2.6.0' compile(group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version: 'latest.release') { exclude group: 'org.apache.commons.io' }}

到我项目的build.gradle文件.在更改项目的build.gradle文件后, speech-android-wrapper 的build.gradle文件如下所示.

to my project's build.gradle file. While I have changed my project's build.gradle file, build.gradle file of speech-android-wrapper look like below.

dependencies { compile files('libs/java_websocket.jar') //compile files('libs/commons-io-2.4.jar') compile 'commons-io:commons-io:2.4' compile files('libs/jna.jar')}

dependencies { compile files('libs/java_websocket.jar') //compile files('libs/commons-io-2.4.jar') compile 'commons-io:commons-io:2.4' compile files('libs/jna.jar')}

但是对我没有任何作用.

But nothing works for me.

推荐答案

我找到了解决方案,因为可以排除以下几行.

I found the solution, as one can exclude some group my following line.

configurations { all*.exclude group: 'commons-io'}

configurations { all*.exclude group: 'commons-io'}

我在上面添加的行错误消失了.

I have added above line error disappears.

这篇关于重复输入错误-依赖关系和项目模块冲突-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 06:18