Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/suppor

小米1s(4.1.2)和红米(4.4.4)run项目时报这个错:
三星a8(android5.1.1)run项目时没有报这个错, 不给项目打包时也会报错:
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnimRes;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnimatorRes;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnyRes;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/ArrayRes;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AttrRes;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/BinderThread;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/BoolRes;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/CallSuper;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/CheckResult;
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Translation has been interrupted
:ziroomer_quality:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ‘:ziroomer_quality:transformClassesWithDexForDebug’.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:\Java\jdk1.8.0_66\bin\java.exe’’ finished with non-zero exit value 2

问题说明: 看起来是jar包引用重复, 可能其他原因引起, 自动好了(在高版本android(>5.0))上直接运行没问题,在<5.0的4.x.x上运行时就会报错, 打包也会出错.
原因分析:
查看项目的External Libraries: 如下,
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/suppor_第1张图片

会发现跟gradle配置中v7包版本一致的support-annotations-23.3.0的jar包,其他的jar包里肯定也有一个annotations的jar包,这样我们排除掉v7包中的annotations的jar,问题应该可以解决.
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/suppor_第2张图片

果然没有再报annotations重复的问题,运行项目,以为万事大吉了,又出现了v4包的重复问题,
尝试把v7包中的v4包也排除掉:
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/suppor_第3张图片

运行项目, 功夫不负有心人, 终于, 项目可以在android4.1.2和4.4.4的手机上运行了.
问题总结: 当碰到Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: 或者Multi Dex这样的error时, 一般是因为项目中的相关jar包重复了. 我们找到一处重复的jar包, 将它排除掉或删掉, 问题一般可以解决, 如果有三处以上那就得好好找找并相应处理了. 谢谢大家.

你可能感兴趣的:(Android,eclipse)