SendGrid for android" Dependency在发布时被忽略,因为它可能与Android提供的内部版本冲突

时间:2016-08-30 15:28:38

标签: android gradle sendgrid

我正在使用The SendGrid for Android库,当我添加依赖项时:

compile 'com.github.danysantiago:sendgrid-android:1'

我收到警告:

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

为什么我会收到此错误,如何解决?

2 个答案:

答案 0 :(得分:3)

如果您已经获得Apache库并且在添加packingOptions后仍然无法正常工作,请尝试使用

compile 'com.github.danysantiago:sendgrid-android:1',{
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

答案 1 :(得分:1)

文档很清楚,也许你忘记了这一点:

由于图书馆使用Apache's Http Library的更新版本,我们需要添加以下打包选项,以便正确构建APK,而不会发生库冲突。这将进入你应用的build.gradle。

...
android {
   ...
    packagingOptions {
         exclude 'META-INF/NOTICE'
         exclude 'META-INF/LICENSE'
   }
}

修改

我的应用build.gradle文件:

 android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.hackerli.view"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}
 }

 dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.2.1'
      compile 'com.github.danysantiago:sendgrid-android:1'
 }