在Android studio 3.0 Beta 5中运行应用程序时,我面临多索引问题

在Android studio 3.0 Beta 5中运行应用程序时,我面临多索引问题,android,android-multidex,Android,Android Multidex,我遵循了这个解决方案的各种链接,但没有任何效果。 以下是错误: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex 我还启用了multidex,并在build.gradle文件的底部添加了google services插件。以下是build.gradle编译器依赖项: compile fileTree(include: '*.jar', dir

我遵循了这个解决方案的各种链接,但没有任何效果。 以下是错误:

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我还启用了multidex,并在build.gradle文件的底部添加了google services插件。以下是build.gradle编译器依赖项:

compile fileTree(include: '*.jar', dir: 'libs')
compile files('libs/universal-image-loader-1.9.5.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
    transitive = true;
}

compile 'com.android.support:design:26.0.1'
compile 'com.android.support:mediarouter-v7:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.5.+'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
    exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile 'com.google.firebase:firebase-messaging:11.4.0'
compile 'junit:junit:4.12'
compile 'com.nineoldandroids:library:2.4.0'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.1.2'
testCompile 'org.robolectric:shadows-multidex:3.1.2'
testCompile 'org.robolectric:shadows-httpclient:3.1.2'
testCompile 'org.robolectric:shadows-support-v4:3.1.2'
compile files('libs/beacon_sdk.jar')
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
    exclude module: "httpclient"
}

compile 'com.google.android.gms:play-services:11.4.0'
compile 'com.google.firebase:firebase-core:11.4.0'
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'org.apache.commons:commons-lang3:3.5'
compile 'com.android.support:cardview-v7:26.0.1'
试试这个 拆分google play服务它将发挥作用

使用这个

    compile 'com.google.android.gms:play-services-analytics:11.4.0'
    compile 'com.google.android.gms:play-services-drive:11.4.0'
    compile 'com.google.android.gms:play-services-location:11.4.0'
    compile 'com.google.android.gms:play-services-places:11.4.0'
    compile 'com.google.android.gms:play-services-gcm:11.4.0'
    compile 'com.google.android.gms:play-services-plus:11.4.0'
compile 'com.google.android.gms:play-services:11.4.0'
而不是这个

    compile 'com.google.android.gms:play-services-analytics:11.4.0'
    compile 'com.google.android.gms:play-services-drive:11.4.0'
    compile 'com.google.android.gms:play-services-location:11.4.0'
    compile 'com.google.android.gms:play-services-places:11.4.0'
    compile 'com.google.android.gms:play-services-gcm:11.4.0'
    compile 'com.google.android.gms:play-services-plus:11.4.0'
compile 'com.google.android.gms:play-services:11.4.0'

Android 5.0(API级别21)之前的平台版本使用Dalvik运行时来执行应用程序代码。默认情况下,Dalvik将应用程序限制为每个APK的单个classes.dex字节码文件。为了克服此限制,您可以将multidex支持库添加到项目中:

添加以下依赖项

  android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
}

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



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

@Aditi注意:如果您的项目配置为使用minsdk版本20或更低版本的multidex,并且您部署到运行Android 4.4(API级别20)或更低版本的目标设备,则Android Studio将禁用Instant Run。我正在使用Android 25和minsdk的设备上运行应用程序,应用程序为19@Aditi禁用即时运行。在禁用instant run之后,我现在得到一个错误:多个dex文件定义Lcom/android/volley/DefaultRetryPolicy;清理重建运行@Aditi