错误:以非零退出值2结束

时间:2016-07-13 10:34:32

标签: android android-studio

我的Android Studio存在问题。当我在我的项目中添加AndroidNetworking并修改Manifest.xml时,它给了我这个错误

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/androidnetworking/AndroidNetworking;
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
  

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files \ Java \ jdk1.7.0_75 \ bin \ java.exe''已完成具有非零退出值2

这是Android Manifest的代码(我添加了标记<uses-sdk/>):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="damasoft.mmchat">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" tools:overrideLibrary="com.androidnetworking"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <provider
        android:name="com.ianhanniballake.localstorage.LocalStorageProvider"
        android:authorities="com.ianhanniballake.localstorage.documents"
        android:enabled="@bool/use_provider"
        android:exported="true"
        android:grantUriPermissions="true"
        android:permission="android.permission.MANAGE_DOCUMENTS" >
        <intent-filter>
            <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
        </intent-filter>
    </provider>
    <activity
        android:name="com.ipaulpro.afilechooser.FileChooserActivity"
        android:enabled="@bool/use_activity"
        android:exported="true"
        android:label="@string/choose_file" >
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.OPENABLE" />

            <data android:mimeType="*/*" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Page1" android:label="ManuPost"></activity>
    <activity android:name=".FileChooserActivity"></activity>
</application>

这是我的build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "damasoft.mmchat"
    minSdkVersion 9
    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.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.amitshekhar.android:android-networking:0.0.1'
}

我试图在build.gradle中解决此问题,但没有成功

2 个答案:

答案 0 :(得分:0)

删除您的Build文件夹,然后删除文件&gt; Invalidate Cache&amp;重启和GT;然后再次构建并运行。

答案 1 :(得分:0)

在你的gradle文件中将multiDexEnabled设为true,如

defaultConfig {
    applicationId "com.am.android"
    minSdkVersion 13
    targetSdkVersion 23
    // Enabling multidex support.
    multiDexEnabled true
}

并编译

 compile 'com.android.support:multidex:1.0.1'

在您的主要活动

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}