0
Caused by: com.android.dex.DexException: Multiple dex files define Lcom/esotericsoftware/reflectasm/MethodAccess;

The above error is preventing my Android project from building, I'm using Kryonet and including it in my build.gradle as a dependency below.

dependancies{
    implementation group: 'kryonet', name: 'kryonet', version: '2.21'
    implementation group: 'com.esotericsoftware', name: 'kryo', version: '4.0.1'

It seems both Kryo and Kryonet include this class, but I don't know how to go about resolving the issue, I can't simply remove Kryo because then I lose access to the serialization libraries.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Renari
  • 822
  • 7
  • 16
  • 32
  • I found that I can work around this issue by not using gradle and including all of the individual jars from the Kryonet release in my libs folder. Although it would be nice to be able to have gradle acquire these files instead. – Renari Dec 08 '17 at 20:48

1 Answers1

2

If you run gradle app:dependencies you can notice that the dependencies tree is:

+--- kryonet:kryonet:2.21
|    +--- com.esotericsoftware.reflectasm:reflectasm:1.07
|    +--- com.esotericsoftware.minlog:minlog:1.2    
|    \--- org.objenesis:objenesis:2.1 -> 2.5.1
+--- com.esotericsoftware:kryo:4.0.1
|    +--- com.esotericsoftware:reflectasm:1.11.3
|    |    \--- org.ow2.asm:asm:5.0.4
|    +--- com.esotericsoftware:minlog:1.3.0
|    \--- org.objenesis:objenesis:2.5.1

They have exactly the same dependencies, but Kyro depends on newer versions. So I would simply remove the dependency on kyronet

implementation group: 'kryonet', name: 'kryonet', version: '2.21'

EDIT

This should solve your problem and let you keep both of the libraries

implementation (group: 'kryonet', name: 'kryonet', version: '2.21') {
    exclude group: 'com.esotericsoftware.reflectasm', module: 'reflectasm'
    exclude group: 'com.esotericsoftware.minlog', module: 'minlog'
}
implementation group: 'com.esotericsoftware', name: 'kryo', version: '4.0.1'
Roberto Martucci
  • 1,237
  • 1
  • 13
  • 21