0

"Conversion to Dalvik format failed with error 1" continuously appears and tried several answer threads including this one too.
"Conversion to Dalvik format failed with error 1" on external JAR
Below is the project structure.

project structure


The problem is with the "xerces.jar". When it is removed from "libs" folder the project can be run successfully, but without the .jar file, application can't be run as exceptions occur. What should I do?

Community
  • 1
  • 1
vidulaJ
  • 1,232
  • 1
  • 16
  • 31

2 Answers2

1

You need to add your xerces.jar file to as a Referenced libraries. For that use

 Project -> Right Click ->Properties -> Java Build Path -> Libraries ->Add External Jars.

Then also add to your libs folder too.

Unchecked your Android Private Libraries and Android Dependencies in Order and Export Menu. Finally run your project and build it.

Piyush
  • 18,895
  • 5
  • 32
  • 63
1

The reason you get this error is because you have multiple java files with the same package and class name(same FQN).

(Rare) If you have the same file in two separate jars then you are in for a ride of manipulating these jars.

(Common) If you have jar in the lib folder, don't add them to the classpath manually as the ADT adds them to the classpath via this line

<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>

This way you only need to check the export of the libraries node in the classpath tab.

TacB0sS
  • 10,106
  • 12
  • 75
  • 118
  • The thing is the project worked on the day before and didn't work on yesterday. Actually, I haven't manually added jars to classpath folder and it remains the same. – vidulaJ Nov 14 '14 at 03:53
  • Make sure there are no duplicated exports on all projects, Libraries, and lib folder, and also with sub-projects(dependencies) classpaths. NOTE: if you use the latest ADT it will let you know there is the same library name with different MD5(versions). – TacB0sS Nov 14 '14 at 21:07
  • Wait just a second there.... the xerces lib is in both the libs folder and added as library... that is your bug... remove it from your Libraries **tab** (Project -> Right Click -> Properties -> Java Build Path -> Libraries) and it should be fine! – TacB0sS Nov 14 '14 at 21:09
  • I have tried that too TacB0sS! Didn't work too. The funny thing was, there was a previous version of the application opened in ADT and I copied and pasted "res" and "src" folders and worked fine. I really don't have any idea what is going on here. – vidulaJ Nov 17 '14 at 03:46