关于集成Bmob遇到的坑

 

1.因为我的项目用到的开源组件比较多,所以遇到了不少坑,在这里给大家分享一下。

2.首先我列举报的错误:

         Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lrx/android/BuildConfig;

       Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lokhttp3/Address;

    Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lrx/android/BuildConfig;

3.上面的错误是我分别遇到的,大家也看明白了是包冲突,当时我就懵逼了,那么多包从哪里找起,于是我用最笨的方法解决:

这样挨个的找,不过还是解决了,后面又报:

 

二、问题分析:

1、 rxandroid:1.1.5 在 dependencies 并没有添加1.1.5版本(注意工程中添加的是rxandroid:2.0.1),此lib从何而来?

答案是肯定的,显然在dependencies 添加的其他libs中有使用到 rxandroid:1.1.5 版本的。

2、多余的rxandroid:1.1.5 是被那个lib使用到的呢?如何知道呢?

在文件目录下或 Android Studio的 Terminal下敲

gradlew -q app:dependencies

便有各个libs引用关系的输出:

+--- com.squareup.okhttp3:okhttp:3.6.0
|    \--- com.squareup.okio:okio:1.11.0
+--- org.greenrobot:eventbus:3.0.0
+--- com.jakewharton:butterknife:8.5.1
|    +--- com.jakewharton:butterknife-annotations:8.5.1
|    |    \--- com.android.support:support-annotations:25.1.0 -> 25.1.1
|    +--- com.android.support:support-annotations:25.1.0 -> 25.1.1
|    \--- com.android.support:support-compat:25.1.0 -> 25.1.1 (*)
+--- io.reactivex.rxjava2:rxandroid:2.0.1
|    \--- io.reactivex.rxjava2:rxjava:2.0.1
|         \--- org.reactivestreams:reactive-streams:1.0.0
+--- io.reactivex.rxjava2:rxjava:2.0.1 (*)
+--- com.google.code.gson:gson:2.7
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0 -> 3.6.0 (*)
+--- com.squareup.retrofit2:converter-gson:2.1.0
|    +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
|    \--- com.google.code.gson:gson:2.7
\--- com.squareup.retrofit2:adapter-rxjava:2.1.0
     +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
     \--- io.reactivex:rxjava:1.1.5

通过各个libs引用的关系图,就可以清楚的看出:

adapter-rxjava:2.1.0 中使用的是 io.reactivex:rxjava:1.1.5

 

三、问题解决:

1、知道是那个libs中和rxandroid:1.1.5 ,问题就好解决了,直接

exclude 问题解决!

compile (‘com.squareup.retrofit2:adapter-rxjava:2.1.0’){ 
exclude module: ‘rxjava’ 
}

 希望对于第一次集成Bmob的同学有帮助

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值