无法生成签名的APK? [DuplicatePlatformClasses发生错误]

时间:2018-08-20 05:32:07

标签: android http android-studio-3.0

我收到此错误

错误:xpp3定义了与Android现在提供的类冲突的类。解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp替代),或使用jarjar之类的库重新打包该库。 [DuplicatePlatformClasses]

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

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

2 个答案:

答案 0 :(得分:1)

尝试一下

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

答案 1 :(得分:0)

我有类似的问题。 Apache库已在整个项目中使用,我无法排除该库。今天,我尝试使用jar文件来代替它,并且有效。您可以从此处下载apache http库jar文件: https://jar-download.com/artifacts/org.apache.httpcomponents