https://blog.csdn.net/richiezhu/article/details/80320185

按住两次SHIFT 进行类名搜索,然后再gradle中 配置configruations,all*.exclude 这个module ''

apply plugin: 'com.android.application'android {    compileSdkVersion 28    defaultConfig {        applicationId "com.keraseye.xkk.keraseye"        minSdkVersion 21        targetSdkVersion 28        multiDexEnabled true        javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"        externalNativeBuild {            cmake {                cppFlags "-std=c++14"            }        }    }    packagingOptions {        exclude 'META-INF/DEPENDENCIES'        exclude 'META-INF/DEPENDENCIES.txt'        exclude 'META-INF/LICENSE'        exclude 'META-INF/LICENSE.txt'        exclude 'META-INF/license.txt'        exclude 'META-INF/NOTICE'        exclude 'META-INF/NOTICE.txt'        exclude 'META-INF/notice.txt'        exclude 'META-INF/INDEX.LIST'    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    externalNativeBuild {        cmake {            path "CMakeLists.txt"        }    }}dependencies {    implementation fileTree(include: ['*.jar'], dir: 'libs')    implementation 'com.android.support:appcompat-v7:28.0.0'    implementation 'com.android.support.constraint:constraint-layout:1.1.3'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.2'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'    implementation 'org.deeplearning4j:deeplearning4j-core:0.7.2'    implementation 'org.nd4j:nd4j-native:0.7.2'    implementation 'org.nd4j:nd4j-native:0.7.2:android-x86'    implementation 'org.nd4j:nd4j-native:0.7.2:android-arm'    implementation 'org.deeplearning4j:deeplearning4j-modelimport:1.0.0-beta3'}configurations {    all*.exclude module:'nd4j-base64'}

情况1:个例
build.gradle 中

 dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        //
    }
改成

 dependencies {
         //目前最新版【2018年05月15日】
         classpath 'com.android.tools.build:gradle:3.1.2'
        //
    }
情况2:确实是依赖冲突
Error: Program type already present: android.support.v4.app.xxx

例子: 
引入以下依赖报该错误

//Paho Android Service
    implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
    implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
执行命令:

gradlew -q app:dependencies
 


排查 support-v4 出现的依赖关系中 发现 org.eclipse.paho:org.eclipse.paho.android.service:1.0.2 
依赖了 com.google.android:support-v4 注意不是 com.android.support:support-v4 !!!

坑:

//刚开始下意识去写了个排除,发现没有用。。。,原因就是它用 com.google.android:support-v4 不是 com.android.support
    implementation('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'){
          exclude group: 'com.android.support', module: 'support-v4'
      }
总结: 
找到依赖的问题根源后进行排除,按提示报错的来灵活处理冲突问题!

排除方式1:

configurations {
   all*.exclude group: 'com.google.android', module: 'support-v4'
   //或者粗暴点,就没有上面的坑了  all*.exclude module: 'support-v4'
}
dependencies {
...
    implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
    implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
...
}
排除方式2:

 implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
 implementation('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
         exclude(group: 'com.google.android', module: 'support-v4')
    }

/* 或者粗暴点,就没有上面的坑了
implementation('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
        exclude module: 'support-v4'
    }
    */

com.android.support:xxx 等官方依赖包 v4 v7 v13 等版本号保持一致 比如 27.1.1
--------------------- 
作者:路易斯睿齐 
来源:CSDN 
原文:https://blog.csdn.net/richiezhu/article/details/80320185 
版权声明:本文为博主原创文章,转载请附上博文链接!

更多相关文章

  1. 在mac 上配置AndroidStudio碰到的坑
  2. android ACTION_BOOT_COMPLETED接收不到的情况
  3. android 依赖冲突解决
  4. android listview ScrollView冲突 listview checkbox
  5. registerActivityLifecycleCallbacks 的用途
  6. android学习——处理 EditText 右下角为Done,回车 的情况
  7. 解决类似微信聊天界面软键盘和表情框冲突问题
  8. Android(安卓)java.io.IOException异常情况整理
  9. Android-横屏应用在竖屏情况下解锁引起销毁

随机推荐

  1. MySQL找出未提交事务的SQL实例浅析
  2. 开启MySQL远程连接的方法
  3. MySQL如何插入Emoji表情
  4. MySQL压力测试工具Mysqlslap的使用
  5. MySQL SQL优化教程之in和range查询
  6. SQL优化教程之in与range查询
  7. MySQL锁阻塞的深入分析
  8. mysql查看死锁与去除死锁示例详解
  9. Mysql查看死锁与解除死锁的深入讲解
  10. mysql插入前判断数据是否存在的操作