Reason of Conversion to dalvik format failed with error 1

When i have started working on Android 2.1 application, i was very new to Android, Java programming and Eclipse. I have just started without understanding android platform. I just started programming using Android Development SDK and documentation. I  was very happy while i was doing this because every think is going very smooth and i have created tabbed UI and other stuffs like http connections.

In my project i have to use some open source lib to parse different file header. For this i have googled and find lot of java lib (jar files). But when i have tried to use these library in my Android application i was getting exception i.e. “conversion to dalvik format failed with error 1”. I searched on net and find very common answer that clean your project and rebuild it and like this and it worked with some library and not with others.

This error also comes when you change target platform or changing workspace or some library and it will be fixed by doing clean and rebuild.

But i was not able to find exact reason behind this error what is dalvik format then have realized that i need to read some documentation of android application framework and about dalvik virtual Machine.

What is Dalvik Format ?

Dalvik is a virtual machine on Android OS which is register based while other Virtual machines are stack based. Dalvik Virtual Machine is a register based VM is optimized for low memory and processing retirements and OS can run multiple instance of VM to provide isolation of processes. Dalvik VM actually not executes java byte code classes but it executes Dex (Dalvik Execution Format) format classes.

To convert java class to Dex android sdk provides DX tool which converts regular java byte code classes to .dex format classes. Dex file contains more than one class and usually size is less than normal java compressed jar file.

Why “conversion to dalvik format failed with error 1” occurs?

But this DX tool can not convert all java classes to dex format then this error occurs. In my case when i was getting error because there are some class which are using Java standard edition references and can not converted to dex. Generally it will convert all J2Me lib to dex format.

Second scenario is that when you are changing target platform or work space then there might be some inconsistency in build and it was fixed by just cleaning and rebuilding workspace.


So please clean your project and rebuild it when you are getting this exception but when some classes which can not be converted to dex format are used then you can not use those classes in Android application.

Leave a Reply

Your email address will not be published. Required fields are marked *