DataBinding 1.DexArchiveMergerEx

2018-11-29  本文已影响0人  Android__Tower

在给项目中添加dataBinding{ enabled = true } 后安装时报错:
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/LoaderManager

Error.png

具体解决方法如下:
错误的gradle引用:

    implementation fileTree(include: ['*.jar'], dir: 'libs')
   implementation 'com.android.support:appcompat-v7:27.1.1'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'com.android.support.test:runner:1.0.2'
   androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

正确的gradle引用:

   implementation fileTree(include: ['*.jar'], dir: 'libs')
   testImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
       exclude group: 'com.android.support', module: 'support-annotations'
   })
   implementation 'com.android.support.constraint:constraint-layout:1.0.2'
   testImplementation 'junit:junit:4.12'
   implementation 'com.android.support:appcompat-v7:26.0.2'

换成下面的引用方式 完美运行。

上一篇下一篇

猜你喜欢

热点阅读