在引入GSON时,编译出现下面的错误
Duplicate class com.google.gson.internal.bind.TypeAdapters$9 found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.internal.bind.util.ISO8601Utils found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.reflect.TypeToken found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.stream.JsonReader found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.stream.JsonReader$1 found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.stream.JsonScope found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.stream.JsonToken found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.stream.JsonWriter found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)
Duplicate class com.google.gson.stream.MalformedJsonException found in modules gson-2.7 (gson-2.7.jar) and gson-2.8.7 (com.google.code.gson:gson:2.8.7)Go to the documentation to learn how to Fix dependency resolution errors.
只需要加入下面的代码即可
configurations { all*.exclude group: 'com.google.code.gson' }
添加的位置