我已经按照这个解决方案的各种链接但没有任何效果。 以下是错误:
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我还启用了multidex并在build.gradle文件底部添加了google服务插件。这是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'
答案 0 :(得分:2)
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>
如果你覆盖了Application类但是无法更改基类,那么你可以改为覆盖attachBaseContext()方法并调用MultiDex.install(this)来启用multidex:
public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
答案 1 :(得分:1)
试试这个 拆分谷歌播放服务它将起作用
使用此
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'