Android Dx Error1, Failed to convert to Dalvik format

允我心安 提交于 2019-12-04 16:04:59

The problem is that the jar you are including has a class in the java.* or javax.* namespace. dx does not allow this, as mentioned in the last big error message.

If you actually need these classes, you'll need to move them to a different package, using something like the jarjar tool. Otherwise, you'll need to remove them from the jar -- it may be possible to have proguard to remove them before everything gets dx'd, I'm not sure.

I faced the same problem, I finally resolved it by exporting my private library explicitly.

Like: Project >> properties >> Java Build Path >> Libraries >> Add External Jars.

Note: Removed my all private libraries from libs folder. I know it is not correct but it worked for me.

Thanks, Anil

Sandeep_Devhare

Do as follows :

project
  > properties
    > java build path
      > libraries
        > remove all including android jars

Now, go the project browser, right click on the project you are working on, then

android tools
  > fix project properties.

Do a clean and then build.

Just restart eclipse, and the error won't occur anymore

If you work on Win7 change this line:

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*     

in proguard.bat file to this:

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9     

proguard.bat is in:

[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat

Edit:
I hope a combine of these help you:
1-Try to delete libraries projects from your project.
2-Try to export your project(as archive file),delete project and it's source from workspace and then import it again.
3-Try to remove your jars from path,do clean-build and then add them again to your project.

I had the same error when using my own obfuscated lib jar.

my log:

warning:Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribte.This class was probably prouduced by a compiler that did not target the morden .class file format...

And I solved it like this:before I obfuscate my jar,I added "-keepattributes EnclosingMethod" to the proguard.cfg(or proguard-project.txt in latest android adt version).

Agree with hasanghaforian. The easiest solution is to remove libraries project. Right click your project->Properties->Java Build Path then remove Library Projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!