android - 无法生成签名的 apk? [发生重复平台类错误]

标签 android http android-studio-3.0

我收到这个错误,

错误:xpp3 定义的类与 Android 现在提供的类冲突。解决方案包括寻找更新版本或没有相同问题的替代库(例如,对于 httpclient,请改用 HttpUrlConnection 或 okhttp),或使用 jarjar 之类的东西重新打包库。 [重复平台类]

同时生成签名的 apk。我怎么解决这个问题。请帮助我!!

应用 Gradle ,

 apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '25.0.2'

defaultConfig {
    applicationId "com.casperon.app.rydepass"
    minSdkVersion 17
    targetSdkVersion 26
    versionCode 17
    versionName "4.2"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
aaptOptions {
    cruncherEnabled = false
}

dexOptions {
    javaMaxHeapSize "4g"
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}

useLibrary 'org.apache.http.legacy'
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':slideDateTimePicker')
compile project(':CountryCodePicker')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.android.support:multidex:1.0.3'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
compile 'com.squareup:android-times-square:1.6.5@aar'
compile 'com.google.android.gms:play-services:11.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.d-max:spots-dialog:0.7@aar'
compile 'com.android.support:support-annotations:24.0.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
compile 'com.github.ganfra:material-spinner:1.1.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.googlecode.libphonenumber:libphonenumber:8.7.0'
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.2'
compile 'me.drakeet.materialdialog:library:1.2.2'
compile 'com.wang.avi:library:1.0.1'
compile 'com.android.support:design:24.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.prolificinteractive:material-calendarview:1.4.2'
compile 'org.igniterealtime.smack:smack-android:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-im:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-extensions:4.1.0-rc1'
compile 'net.hockeyapp.android:HockeySDK:3.5.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.crazy1235:RichEditText:v2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'com.squareup:android-times-square:1.6.5@aar'
  //noinspection DuplicatePlatformClasses
 /* compile 'org.apache.httpcomponents:httpclient:4.5'*/
'org.apache.httpcomponents:httpclient:jar:4.5.6'

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

最佳答案

试试这个,

   configurations {
    all*.exclude group: 'xpp3', module: 'xpp3'
    compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}

关于android - 无法生成签名的 apk? [发生重复平台类错误],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51924623/

相关文章:

android - 在 api 23 及以下版本中获取 Http 状态 400

android - 从 Android 相机拍摄的照片是全黑的

actionscript-3 - AS3 POST 请求作为 GET 发送

安卓模拟器无法上网

java - 为什么 UML 显示 Android Adapter 接口(interface)有一个 View 和一个 ViewGroup

android - setChecked 单选按钮无法正常工作

php - 使用 post 和 JWS 发送 JSON 数据

php - 如何使用户配置文件成为 domain.com/username 而不是 domain.com/profile.php?user=username?

安卓工作室模拟器 : Process finished with exit code 255

Android Studio 3.0 - 警告alarmManager可能会产生NullPointerException