Dependency apache HTTP client in android with Goog

2019-06-27 23:47发布

I have been using the google play services libraries just with Google+ login and it worked fine but now I want to include the Calendar API to my app. I am following this tutorial

The problem is that the dependencies with the new instructions of the tutorial cause a Warning in the Gradle Build.

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources]
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex100Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
Information:2 warnings
:app:mergeDebugAndroidTestResources UP-TO-DATE
Information:See complete output in console
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
Information:BUILD SUCCESSFUL
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
Information:0 errors
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
Information:Total time: 10.856 secs
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:app:prepareDebugDependencies
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE

Here is my gradle app file:

apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
            keyAlias 'androiddebugkey'
            keyPassword 'android'
            storeFile file('C:/Users/Julio/.android/debug.keystore')
            storePassword 'android'
        }
    }
    compileSdkVersion 22
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.example.julio.competicionpartido"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.config
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile ('com.google.api-client:google-api-client:1.20.0'){
        exclude module: 'httpclient' 
        exclude group: 'org.apache.httpcomponents'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient' 
    }
    compile 'com.google.api-client:google-api-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-gson:1.20.0'
    compile 'com.google.apis:google-api-services-calendar:v3-rev125-1.20.0'
}

I have been searching for ages and I've tried everything. Could anyone help me?

3条回答
成全新的幸福
2楼-- · 2019-06-28 00:17

I could fix the error by excluding the module httpclient from all configurations. Add this code to your guild.gradle file:

configurations {
    compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
查看更多
男人必须洒脱
3楼-- · 2019-06-28 00:19

in order to exclude that class from all the configurations:

configurations.all() {
    exclude group: "org.apache.httpcomponents", module: "httpclient"
}

dependencies {
    ...
}
查看更多
小情绪 Triste *
4楼-- · 2019-06-28 00:24

I solved it this way..

I had integrated google+ signin, and sharing with my application. I just removed dependencies for API client dependency and just I had used just google play service dependency and it worked for me.

compile 'com.google.api-client:google-api-client-android:1.20.0'- remove it

and

just use compile 'com.google.android.gms:play-services:7.5.0' and all works fine.

查看更多
登录 后发表回答