【问题标题】:Multiple dex files define Lcom/google/android/gms/common/AccountPicker;多个dex文件定义Lcom/google/android/gms/common/AccountPicker;
【发布时间】:2018-01-15 14:16:59
【问题描述】:

我来了

将字节码转换为 dex 时出错:\n原因: com.android.dex.DexException: 多个 dex 文件定义 Lcom/google/android/gms/common/AccountPicker;

暂时看不出原因。 清洁没有帮助。

项目 build.gradle:

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

buildscript {
    repositories {

        jcenter()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath "io.realm:realm-gradle-plugin:2.0.2"
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

应用程序构建.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'realm-android'

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "a.b.c.d"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 6
        versionName "1.0.5"
    }
    buildTypes {

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        jumboMode = true
    }
}

dependencies {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://jitpack.io" }
    }
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:transition:24.2.0'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.android.support:support-v13:24.2.0'
    compile 'com.appyvet:materialrangebar:1.3'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.0'
    compile 'com.github.jkwiecien:EasyImage:1.2.3'
    compile 'com.amazonaws:aws-android-sdk-core:2.3.0'
    compile 'com.amazonaws:aws-android-sdk-s3:2.3.0'
    compile 'com.github.chrisbanes:PhotoView:1.3.0'
    compile files('libs/signalr-client-sdk.jar')
    compile files('libs/signalr-client-sdk-android.jar')
    compile 'com.afollestad.material-dialogs:core:0.9.1.0'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.makeramen:roundedimageview:2.3.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
    compile 'me.leolin:ShortcutBadger:1.1.13@aar'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.2.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
    compile files('libs/google-play-services.jar')
}

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

【问题讨论】:

  • 您真的需要所有 Google Play 服务库吗?只使用需要的模块。

标签: android android-studio android-gradle-plugin build.gradle


【解决方案1】:

在 app build.gradle 中尝试multiDexEnabled true

【讨论】:

    【解决方案2】:

    将字节码转换为 dex 时出错:\n原因: com.android.dex.DexException:多个 dex 文件定义 Lcom/google/android/gms/common/AccountPicker;

    问题

    同样的com.google.android.gms:play-services

    解决方案

    build.gradle本地 lib 文件夹中删除 google-play-services

     compile files('libs/google-play-services.jar')
    

    之后Clean-Rebuild-Run

    【讨论】:

    • 试过了,现在我得到:错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/common/AccountPicker.class
    • @SirKnigget 评论compile 'com.google.android.gms:play-services:10.0.1'
    • 我已经'编译'com.google.android.gms:play-services-location:10.0.1'
    • @SirKnigget 你删除了libs/google-play-services.jar' 吗?
    • 现在它可以工作了 - 我删除了 ' compile files('libs/google-play-services.jar')' 并且我必须在它工作之前从 libs 文件夹中删除这个 .jar。不需要多索引。请更新答案,我会接受。
    【解决方案3】:

    您将同一类添加两次。

    删除这一行:

    compile files('libs/google-play-services.jar')
    

    由于您使用的是compile fileTree(include: ['*.jar'], dir: 'libs'),因此您还必须删除文件libs/google-play-services.jar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-01
      • 2017-08-14
      • 1970-01-01
      • 2018-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多