android

转:

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.

Solution

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值