Warning when building the Gradle of the module

1

I added a library of apache and it gives me a warning when building the gradle. The gradle is the following:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    useLibrary  'org.apache.http.legacy'
    defaultConfig {
        applicationId "es.aandg.demo"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 2
        versionName "1.01"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.firebase:firebase-auth:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.github.jd-alexander:LikeButton:0.2.1'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: 
'4.5.3'
testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

The warning I get is the following:

  

Warning: WARNING: Dependency org.apache.httpcomponents: httpclient: 4.5.3 is ignored for debug as it may be conflicting with the internal version provided by Android.

    
asked by Adrián Garrido Blázquez 25.07.2017 в 16:44
source

1 answer

1

The classes Apache are currently marked as obsolete in Android , that's why it shows the warning, because it could (according to Google) not work properly.

you have defined the property so that classes can be used in your project

  useLibrary  'org.apache.http.legacy'

however the suggestion is to stop using these classes.

Review this question: Incompatibility in the Android gradle

The option is to use HttpURLConnection , here's an example:

link

    
answered by 25.07.2017 / 16:47
source