本文介绍了Java.exe 在 Android Studio 中以非零退出值 2 结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个错误是在我添加compile 'org.apache.httpcomponents:httpmime:4.2.3'之后出现的.找不到解决方案我也在默认配置部分尝试了多个 dex 文件 true.我还尝试创建另一个应用程序进行测试,该应用程序运行成功.

This error came after when I added compile 'org.apache.httpcomponents:httpmime:4.2.3'. Can't find solution I also tried multiple dex file true in default config section. I also tried creating another app for testing which was running successfully.

错误:任务:app:transformClassesWithDexForDebug"的执行失败.com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' 以非零退出值 2 结束

这是我的 build.gradle 文件.

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        defaultConfig {
            applicationId "com.example.qualwebs.assistme"
            minSdkVersion 19
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
              }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
        compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
        compile 'com.getbase:floatingactionbutton:1.10.1'
        compile 'org.apache.httpcomponents:httpmime:4.2.3'
    }

推荐答案

设置您的应用开发项目以使用 multidex 配置需要您对应用开发项目进行一些修改.具体来说,您需要执行以下步骤:

Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:

  1. 更改您的 Gradle 构建配置以启用 multidex
  2. 修改您的清单以引用 MultiDexApplication 类

修改您的应用 Gradle 构建文件配置以包含支持库并启用多索引输出.

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        ...
        minSdkVersion 19
        targetSdkVersion 23
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

在您的清单中,将 multidex 支持库中的 MultiDexApplication 类添加到应用程序元素中.

In your manifest add the MultiDexApplication class from the multidex support library to the application element.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

已编辑

你可以使用

compile 'org.apache.httpcomponents:httpmime:4.5.1'

阅读

https://developer.android.com/intl/es/tools/building/multidex.html

这篇关于Java.exe 在 Android Studio 中以非零退出值 2 结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 05:28