90

While trying to Generate a signed APK I'm getting this error

Entry name 'classes.dex' collided

Can someone tell me how to solve it? I recently changed the default package name which was com.exmaple to my app's name. It builds correctly but gives this error while trying to generate a signed APK

My android studio version is 4.1.2

cigien
  • 57,834
  • 11
  • 73
  • 112
Sanjid Chowdhury
  • 1,010
  • 1
  • 5
  • 9

3 Answers3

245

You are probably facing this error because you already have a signed APK in your project's "release" folder. Please check for any existing APK and delete it, then try to generate once more.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Tanzim Chowdhury
  • 3,020
  • 2
  • 9
  • 21
  • 58
    I think this will go down in history as one of the most misleading error messages of all time. - Your solution works like a charm ;) – Norbert Hüthmayr Apr 30 '21 at 18:46
  • 2
    this is the second time I am here, for different android studio versions, buld failed with the same message `Entry name 'classes.dex' collided `same cause `app-release.apk` is already in the `release` folder – Ali Tamoor Nov 14 '22 at 12:51
  • I'm surprised they haven't fixed this yet – Tanzim Chowdhury Nov 17 '22 at 09:27
31

I had the same problem and here's how I solved it easily:

  1. Build -> Clean Project
  2. Build -> Generate Signed Bundle / APK..
cigien
  • 57,834
  • 11
  • 73
  • 112
Félix Maroy
  • 1,389
  • 2
  • 16
  • 21
0

Add this code in build.gradle

android {
    packagingOptions {
    exclude 'classes.dex'
    exclude '**.**'
    }
}

https://rtdevs.xyz/how-to-solve-entry-name-classes-dex-collided-in-android-studio/