Multidex已启用 - 仍无法合并dex

时间:2018-03-12 10:56:10

标签: android android-studio gradle kotlin android-multidex

这是我的build.gradle

kops

这是我的Manifest.xml

android {
compileSdkVersion 27
defaultConfig {
    applicationId "xxxx.xxxx.xxxx"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

这些是我的依赖

 <application
    android:name="android.support.multidex.MultiDexApplication"
.../>
由于

仍然是gradle构建失败

  

错误:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。   java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

有人可以找出原因吗? 我有2天的时间来解决这个问题,我仍然没有解决方案

dependencies {
    implementation 'com.android.support:multidex:1.0.3'
    implementation fileTree(include: ['*.jar'], dir: 'libs')


    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    //noinspection GradleCompatible
    implementation 'com.android.support:recyclerview-v7:27.1.0'

    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-crash:11.8.0'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation "com.google.android.gms:play-services-location:11.8.0"
    implementation 'com.google.maps.android:android-maps-utils:0.4.4'
    implementation 'com.google.code.gson:gson:2.8.2'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.anko:anko:0.10.4"
    implementation "org.jetbrains.anko:anko-design:0.10.4"

    //    CircleImage
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    //    Glide
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    //DateTimePicker
    implementation 'com.wdullaer:materialdatetimepicker:3.4.0'

    implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'


    implementation 'com.github.kittinunf.fuel:fuel-android:1.12.0'


    implementation 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'



    implementation project(path: ':regservice')
}

1 个答案:

答案 0 :(得分:0)

创建类似的应用程序类,

  public class MyApplication extends Application {
  @Override
   protected void attachBaseContext(Context base) {
      super.attachBaseContext(base);
      MultiDex.install(this);
   }
  }

使用&#34; MyApplication&#34;而不是android.support.multidex.MultiDexApplication

<application
android:name=".MyApplication"
 />