Android API中的依赖apache HTTP客户端

时间:2015-08-18 09:21:07

标签: android google-api google-plus google-calendar-api android-gradle

我一直在使用谷歌播放服务库只是与Google+登录,它工作正常但现在我想将Calendar API包含到我的应用程序。我正在关注this tutorial

问题在于,使用本教程的新指令的依赖项会导致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

这是我的gradle app文件:

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'
}

我一直在寻找年龄,我已经尝试了一切。有谁可以帮助我?

3 个答案:

答案 0 :(得分:8)

为了从所有配置中排除该类:

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

dependencies {
    ...
}

答案 1 :(得分:4)

我可以通过从所有配置中排除模块httpclient来修复错误。将此代码添加到guild.gradle文件中:

configurations {
    compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}

答案 2 :(得分:2)

我这样解决了..

我已经集成了google + signin,并与我的应用程序共享。我刚刚删除了API客户端依赖项的依赖项,只是我使用了谷歌播放服务依赖项,它对我有用。

compile 'com.google.api-client:google-api-client-android:1.20.0' - 将其删除

只需使用compile 'com.google.android.gms:play-services:7.5.0',一切正常。