DEX错误Android Studio - 任务执行失败':app:transformClassesWithMultidexlistForDebug'

时间:2018-02-28 17:22:36

标签: android android-studio dex

添加Spinner后,我得到了这个奇怪的错误,它有效。我试图为它修复一些余地。尝试建立它有这个错误

任务执行失败':app:transformClassesWithMultidexlistForDebug'。 重复的zip条目[classes.jar:android / support / design / widget / CoordinatorLayout $ Behavior.class]

所以,我尝试删除我添加的内容。没工作。我尝试清理构建项目并重建,但没有成功。它试图在stackoverflow上寻找解决方案。我遇到了,将multiDexEnabled添加到我的app.gradle中,这没有成功。我还在Android链接上关注了它的文档:https://developer.android.com/studio/build/multidex.html

这既不起作用,所以我来到这里是我自己。我的gradle文件:

app.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.meyil.androidlearning"
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:design:26.1.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.firebaseui:firebase-ui-database:3.2.1'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'com.squareup.okhttp:okhttp:2.5.0'
    implementation 'com.android.support:multidex:1.0.2'
}
















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

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.meyil.androidlearning">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:name="android.support.multidex.MultiDexApplication"
        android:allowBackup="true"
        android:icon="@mipmap/spaced_launcher_logo"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/spaced_launcher_logo_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <service android:name=".FirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".StartActivity" />
        <activity
            android:name=".RegisterActivity"
            android:parentActivityName=".StartActivity" />
        <activity
            android:name=".LoginActivity"
            android:parentActivityName=".StartActivity" />
        <activity android:name=".SettingsActivity" />
        <activity
            android:name=".StatusActivity"
            android:parentActivityName=".SettingsActivity" />
        <activity
            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
            android:theme="@style/Base.Theme.AppCompat" />
        <activity
            android:name=".UsersActivity"
            android:parentActivityName=".MainActivity" />
        <activity android:name=".ProfileActivity">
            <intent-filter>
                <action android:name="com.example.meyil.androidlearning_TARGET_NOTIFICATION" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".ChatActivity"
            android:parentActivityName=".MainActivity"></activity>
    </application>

</manifest>

的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

2 个答案:

答案 0 :(得分:0)

昨天有同样的问题,所以检查了依赖关系并删除了&#39; android.lib.recaptcha:reCAPTCHA:+&#39;开始工作正常,构建与任何错误complited。在我看来,你也应该尝试找到冲突的依赖。

答案 1 :(得分:0)

我通过将compileSdk和targetSdk更改为27以及所有其他依赖项26到27来修复它。:D