天天看點

關于OKHTTP和RX及其他三方包沖突的問題,Error: Program type already present: rx.android.BuildConfig

問題描述

  1. Error: Program type already present:okio.AsyncTimeout;
  2. Error: Program type already present: rx.android.BuildConfig;
  3. Error: Program type already present: okio.Buffer$1;
  4. Error: Program type already present: okhttp3.Authenticator$1;
  5. Error: Program type already present: rx.android.BuildConfig;

解決方案

1、`

android {
      packagingOptions {
          exclude 'META-INF/LICENSE'
          exclude 'META-INF/NOTICE'
          exclude 'META-INF/rxjava.properties'
          exclude 'META-INF/rxandroid.properties'
         }
      }      

2、

defaultConfig {
        multiDexEnabled true
    }      

3、`

dependencies {
      configurations {
           /*all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
           all*.exclude group: 'com.squareup.okio'*/
           all*.exclude group: 'com.squareup.okhttp3'
             all*.exclude group: 'com.squareup.okio'
        }
  }      

4、調整jar引用的先後順序。

gradlew -q app:dependencies