Fix “Multiple dex files define L…” Errors

Today I got an error when building the APK:

Multiple dex files define L/…

My scenario is that of a project with 2 modules: a core and an app. Both modules use a plugin named androiddevmetrics, which generate some code, including a class which has the same signature in both modules. The linking (APK generation) resulted in an obvious conflict.

My steps to solve this error are:

  1. Identify which package/module generates the error. The L/com/android/... will tell you exactly who the culpable is. In my case, the idea is to find who generates the duplicate file.
  2. In your main module’s gradle file (app in my case) add, at the end

In my case, the addition looked like:

Note: I only got this error when building the APK, which makes it quite annoying.

A little experiment: If you find this post and ad below useful, please check the ad out :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top