Search code examples
androidgradlelibgdxdalvikdex

multiple dex files - conversion to dalvik format failed


I'm making a game on libgdx and it all worked fine yesterday, but now it's messed up.

[2014-09-18 00:38:39 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/badlogic/gdx/Application$ApplicationType;
[2014-09-18 00:38:39 - birdy-android] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/badlogic/gdx/Application$ApplicationType;

That is the error I got. I've been trying to find an answer and I can't find one that works anywhere.


Solution

  • That happens when you define the same class (with same path) twice. In this case the class is:

    Multiple dex files define Lcom/badlogic/gdx/Application$ApplicationType;

    Which is in the Libgdx core jar.

    So 2 possible escenarios:

    • You created your project manually and added the jar in your build path twice.

    • You created your project using Gradle and you mistakenly added the jar as a dependency twice:

      project(":core") {
          apply plugin: "java"
      
          dependencies {
              compile "com.badlogicgames.gdx:gdx:$gdxVersion"
              compile "com.badlogicgames.gdx:gdx:$gdxVersion" <--
              compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
          }
      }
      

    So, just delete the cloned dependency, or fix your build path to not add the jar twice. (You can always remake the project and copy your old code though).