您好我已经开发了一个应用程序并且已经完成。现在我正在尝试创建发布apk但我得到以下异常
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class
我的应用build.gradle如下 我不明白为什么我的app.debug应用程序运行完全错误发生。我在创建发布时遇到错误apk
apply plugin: 'com.android.application'
repositories { flatDir {
dirs 'libs' }
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
dexOptions {
javaMaxHeapSize "4g" // 2g should be also OK
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'org/apache/http/entity/mime/version.properties'
exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.properties'
exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.xml'
}
defaultConfig {
applicationId "com.XXXX.XXXX"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile(name: 'peb-lib', ext: 'aar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.android.gms:play-services-safetynet:8.3.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.google.android.gms:play-services-analytics:7.3.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.daimajia.androidanimations:library:1.0.3@aar'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.d-max:spots-dialog:0.4@aar'
compile 'com.vlonjatg.android:app-tour:1.0'
compile 'com.mobsandgeeks:android-saripaar:1.0.3'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'org.jsoup:jsoup:1.8.3'
compile 'me.relex:circleindicator:1.2.1@aar'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
}
请提供解决方案,因为我想在playstore上发布app.Thanks提前
答案 0 :(得分:0)
您正在使用两个不同的aar
或jar
依赖项,其中包括apache http客户端。那是你的问题。有一些方法可以检查jar
或aar
文件的内容,例如jadx,但由于您是初学者,因此跟踪和错误方式也应该没问题。
首先,如果您没有jar
个依赖关系,请删除此行:
compile fileTree(dir: 'libs', include: ['*.jar'])
现在从依赖项中排除apache类,例如:
compile 'com.squareup.retrofit:retrofit:1.9.0'
需要转换为:
compile('com.squareup.retrofit:retrofit:1.9.0') {
exclude module: 'httpclient'
}
如果仍然没有编译,请尝试下一个依赖项,依此类推。这应该删除重复的类。
祝你好运!