Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 与apache/http库生成APK冲突_Java_Android_Android Gradle Plugin_Build.gradle - Fatal编程技术网

Java 与apache/http库生成APK冲突

Java 与apache/http库生成APK冲突,java,android,android-gradle-plugin,build.gradle,Java,Android,Android Gradle Plugin,Build.gradle,我可以在使用USB的设备上运行我的应用程序,但当我尝试构建APK时,它会出现以下错误: 错误:任务“:app:transformClassesWithJarMergingForDebug”的执行失败。 com.android.build.api.transform.TransformException:java.util.zip.zipeException:重复条目:org/apache/http/HttpHeaders.class 我的格拉德尔: apply plugin: 'com.andr

我可以在使用USB的设备上运行我的应用程序,但当我尝试构建APK时,它会出现以下错误:

错误:任务“:app:transformClassesWithJarMergingForDebug”的执行失败。 com.android.build.api.transform.TransformException:java.util.zip.zipeException:重复条目:org/apache/http/HttpHeaders.class

我的格拉德尔:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "elryad.harajsooq"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true
    }

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



    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        }
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.2.3'
        compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5'
    //    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    //    compile 'org.apache.httpcomponents:httpclient:4.5'
    //    compile 'org.apache.httpcomponents:httpmime:4.2.3'
        compile files('libs/volley.jar')
        compile 'com.android.support:appcompat-v7:25.3.0'
        compile 'com.android.support:design:25.3.0'
        compile 'com.android.support:support-annotations:25.3.0'
        compile 'de.hdodenhof:circleimageview:1.3.0'
        compile 'com.mcxiaoke.volley:library-aar:1.0.0'
        compile 'com.android.support:palette-v7:25.3.0'
        compile 'com.android.support:recyclerview-v7:25.3.0'
        compile 'com.android.support:cardview-v7:25.3.0'
        compile 'com.squareup.okhttp3:okhttp:3.1.2'
        //compile 'com.android.support:support-v7:25.0.2'
        compile "com.android.support:support-core-utils:25.3.0"
        compile 'com.android.support:support-v13:25.3.0'
        compile 'com.google.code.gson:gson:2.7'
        compile 'com.google.firebase:firebase-messaging:9.0.0'
        compile 'com.google.android.gms:play-services:9.0.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.1'
        compile 'com.squareup.picasso:picasso:2.5.2'
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:multidex:1.0.1'

    }
传统Apache HTTP 您正在将Apache HTTP的一个版本绑定到应用程序中。从所有模块的
build.gradle中删除此行:

useLibrary 'org.apache.http.legacy'
在幕后,该方法实际上包含一个旧版本ApacheHTTP的JAR,如果您通过Gradle/maven管理依赖项,那么这不是您想要的

匹配版本 从ApacheHTTP导入的所有工件必须具有相同的版本

compile 'org.apache.httpcomponents:httpmime:4.5.3'
compile 'org.apache.httpcomponents:httpclient-android:4.5.3'
嗯,代码> HtpCys不遵循这个SeMe,然后再考虑它是一个内部传递依赖关系,适当的版本被使用的任何版本的<代码> HTTPcli客< /代码>自动拉拽。您不必手动指定它

maven中的Apache HTTP工件列表:

Legacy Apache HTTP 您正在将Apache HTTP的一个版本绑定到应用程序中。从所有模块的
build.gradle中删除此行:

useLibrary 'org.apache.http.legacy'
在幕后,该方法实际上包含一个旧版本ApacheHTTP的JAR,如果您通过Gradle/maven管理依赖项,那么这不是您想要的

匹配版本 从ApacheHTTP导入的所有工件必须具有相同的版本

compile 'org.apache.httpcomponents:httpmime:4.5.3'
compile 'org.apache.httpcomponents:httpclient-android:4.5.3'
嗯,代码> HtpCys不遵循这个SeMe,然后再考虑它是一个内部传递依赖关系,适当的版本被使用的任何版本的<代码> HTTPcli客< /代码>自动拉拽。您不必手动指定它


maven中Apache HTTP工件列表:

我在应用程序的许多地方使用了
'org.Apache.HTTP.legacy'
。。有什么办法吗?在匹配apache.http的版本后,会抛出另一个错误:
error:task的执行失败:app:transformClassesWithJarMergingForDebug'>com.android.build.api.transform.TransformException:java.util.zip.zipeException:duplicate entry:com/android/volley/AuthFailureError.class
btw为什么我可以安装应用程序,但我无法构建apk?您正在安装旧的apk。不要导入截击震击器,因为你已经将其导入了thorugh maven。事实上,您可能可以使用JAR的maven instread导入所有内容。要获得更多控制,请删除
编译文件树(dir:'libs',include:['*.jar'])
。我在应用程序的许多地方使用了
'org.apache.http.legacy'
。。有什么办法吗?在匹配apache.http的版本后,会抛出另一个错误:
error:task的执行失败:app:transformClassesWithJarMergingForDebug'>com.android.build.api.transform.TransformException:java.util.zip.zipeException:duplicate entry:com/android/volley/AuthFailureError.class
btw为什么我可以安装应用程序,但我无法构建apk?您正在安装旧的apk。不要导入截击震击器,因为你已经将其导入了thorugh maven。事实上,您可能可以使用JAR的maven instread导入所有内容。要获得更多控制,请删除
编译文件树(dir:'libs',包括:['*.jar'])