首页 > 解决方案 > 错误:程序类型已经存在: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    

标签: androidcompiler-errorsandroid-gradle-plugin

解决方案


我找到了解决该问题的方法;我只是在我的 libs 文件夹中添加库 jackson-core。我删除了它,所以,现在它可以工作了。


推荐阅读