Error Commons-logging defines classes that conflict with classes now provided by Android

1

By putting an application that uses google maps in release :

Use Android studio 3.0.1

app.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.webserveis.app.quickmapview"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "0.0.1"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services-maps:11.6.2'
    implementation 'com.google.android.gms:play-services-location:11.6.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation "android.arch.lifecycle:runtime:1.0.3"
    annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
    implementation "android.arch.lifecycle:extensions:1.0.0"

    implementation 'com.android.support:support-annotations:27.0.2'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    implementation 'com.master.android:permissionhelper:1.3'
    implementation 'com.google.maps.android:android-maps-utils:0.5'
    implementation 'com.opencsv:opencsv:3.9'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

I missed that error:

  

Error: Error: commons-logging defines classes that conflict with   classes now provided by Android. Solutions include finding newer   versions or alternative libraries that do not have the same problem   (for example, for httpclient use HttpUrlConnection or okhttp instead),   or repackaging the library using something like jarjar.   [DuplicatePlatformClasses]

I think it's in the com.opencsv:opencsv:3.9 library that uses obsolete functions

    
asked by Webserveis 02.12.2017 в 21:27
source

1 answer

2

Apparently the dependency of OpenCsv

implementation 'com.opencsv: opencsv: 3.9'

use Apache Libraries which are obsolete and Advise to replace with HttpUrlConnection , for that reason it suggests:

  

for httpclient use HttpUrlConnection or okhttp instead

One option is to exclude these libraries, which may cause your application to not work properly:

android {

   configurations {
        all {
            exclude module: 'commons-logging'
        }
    }
   ...
   ...
}

As another option, activate the legacy mode to support these apache libraries:

android {
    useLibrary 'org.apache.http.legacy'
}

Example:

Apache libraries error http

    
answered by 02.12.2017 / 22:07
source