首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Error com.android.dex.DexException:多个dex文件定义com.android.dex.DexException

Error com.android.dex.DexException:多个dex文件定义com.android.dex.DexException
EN

Stack Overflow用户
提问于 2019-06-11 10:43:59
回答 2查看 582关注 0票数 0

我发现了一个错误:

代码语言:javascript
复制
Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/libraries/places/internal/dh;

我试着打扫和重建这个项目,但没有成功。任何帮助都将不胜感激。

Android Studio 3.0.1

项目级build.gradle

代码语言:javascript
复制
buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {

    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url 'https://jitpack.io'
                }

    }
}

task clean(type: Delete) {

delete rootProject.buildDir

}

App级build.gradle

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {

    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "in.mycrony"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 86
        versionName "2.86"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'
    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.picasso:picasso:2.5.1'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.google.firebase:firebase-database:17.0.0'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.android.libraries.places:places:1.1.0'
    implementation project(':library')

}

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

库级build.gradle

代码语言:javascript
复制
apply plugin: 'com.android.library'

apply from: "quality.gradle"

group = 'com.github.eggheadgames'

android {

    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 13
        versionName "1.5.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        warningsAsErrors true

        disable 'OldTargetApi'
        disable 'GradleDependency'
    }
}

dependencies {


    testImplementation 'org.mockito:mockito-core:1.10.19'

    testImplementation 'org.json:json:20160212'

    implementation 'com.android.support:appcompat-v7:27.1.1'

}

我已经试过了所有的答案,但我无法解决这个错误。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-06-11 11:01:43

原因: com.android.dex.DexException:多个dex文件定义Lcom/google

你应该用其中之一

代码语言:javascript
复制
 implementation 'com.google.android.libraries.places:places-compat:1.1.0'
 implementation 'com.google.android.libraries.places:places:1.1.0' //Remove

然后是Clean-Rebuild-Run.

票数 3
EN

Stack Overflow用户

发布于 2019-06-11 13:08:18

最后,我对Place使用了实现'com.google.android.libraries.places:places:1.0.0‘,并对Picker使用了相同的旧的'com.google.android.gms:play-services’依赖。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56541948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档