关于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引用的先后顺序。

5、在AndroidStudio控制台输入:

gradlew -q app:dependencies  

查看依赖关系,之后删掉多余的依赖jar包。

你可能感兴趣的:(日常错误)