Multiple dex files define Landroid/support/v4/ in android studio

一世执手 提交于 2019-11-27 22:27:48
Huy Tower

So strange,

When I setup my dependencies like this :

repositories {
            mavenCentral()
        }
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.google.android.gms:play-services:+'
}

I still get the First Issue Multiple dex files define error.

But after following these steps:

  • Put the library via Gradle in build.gradle of main module : compile 'com.google.android.gms:play-services:+'

  • Restart Android Studio

  • Sync project with gradle

I no longer get this error.

I had duplicate libraries in my libs directory:

$ ls -la libs/
total 80
drwxr-xr-x   5  wheel    170 25 Sep 22:09 .
drwxr-xr-x  10  wheel    340 25 Sep 22:07 ..
-rw-r--r--   1  wheel   3736 25 Sep 21:36 ApiComponent.jar
-rw-r--r--   1  wheel  28741 25 Sep 21:36 DependencyService.jar
-rw-r--r--   1  wheel   3736 25 Sep 22:09 classes.jar

Removing classes.jar worked for me. I modified my DependencyService Project to produce DependencyService.jar instead of classes.jar causing the duplication.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!