Error: Program type already present: com.fasterxml.jackson.core.Base64Variant

Error: Program type already present: com.fasterxml.jackson.core.Base64Variant

当我编译代码时出现异常:

com.android.tools.r8.utils.AbortException:错误:程序类型已经存在:com.fasterxml.jackson.core.Base64Variant

我知道我应该排除一些传递依赖,但我不知道该怎么做

这些是我的依赖项

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.8'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

代码运行良好,直到我添加了这些行:

 ObjectMapper mapper=new ObjectMapper();
            JsonNode responseNode= null;

            try {
                responseNode = mapper.readTree(response);
            } catch (IOException e) {
                e.printStackTrace();
            }
            assert responseNode != null;
            int SUCCESS = responseNode.get("success").asInt();
            Toast.makeText(getApplication(), SUCCESS, Toast.LENGTH_SHORT).show();

我得到 4 个错误:

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
com.android.tools.r8.CompilationFailedException: Compilation failed to complete 
com.android.tools.r8.utils.AbortException: Error: Program type already present: com.fasterxml.jackson.core.Base64Variant    

我找到了那个问题的解决方案;我只是在我的 libs 文件夹中添加了库 jackson-core 。我删除了它,所以,现在可以使用了。