Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Conversion to Dalvik format failed: Unable to execute dex: null

I'm trying to use the SmugFig SmugMug API on Android. It was designed for J2SE I would imagine, so I'm not sure it will even work on Android, but I figured it was worth trying as opposed to trying to create my own API.

When I load the project though, I get the following error:

Conversion to Dalvik format failed: Unable to execute dex: null

It doesn't say what package it fails on, just "Android Packaging Problem", but it did not do this before I added SmugFig and it's dependency JARS to the build path.

Where should I look? Or does this mainly me that it just won't work with those libraries?

like image 291
Adam Haile Avatar asked Apr 22 '10 01:04

Adam Haile


4 Answers

I found a blog entry that says increase the memory allocated in eclipse.ini to this: -Xms128m -Xmx512m or something higher, but this didn't do it for me.

However, I found another post that suggested doing Project > Clean and that fixed it for me. I think it happens when you shut down Eclipse w/o shutting the emulator down first. Pretty lame bug. Spent a few hours digging for the solution this morning...grrrrrrr :-(

like image 162
ken Avatar answered Nov 09 '22 16:11

ken


Go to Project » Properties » Java Build Path » Libraries and remove all except the "Android X.Y" (in my case Android 1.5). click OK. Go to Project » Clean » Clean projects selected below » select your project and click OK. That should work.

It is also possible that you have a JAR file located somewhere in your project folders (I had copied the Admob JAR file into my src folder) and THEN added it as a Java Path Library. It does not show up under the Package Explorer, so you don't notice it, but it does get counted twice, causing the dreaded Dalvik error 1.

Another possible reason could be package name conflicts. Suppose you have a package com.abc.xyz and a class named A.java inside this package, and another library project (which is added to the dependency of this project) which contains the same com.abc.xyz.A.java, then you will be getting the exact same error. This means, you have multiple references to the same file A.java and can't properly build it.

like image 27
Chu Chau Avatar answered Nov 09 '22 15:11

Chu Chau


After the Eclipse DDMS update 8.0.0 came with the release of Android 2.3 this error suddenly appeared.

None of the above suggestions helped, but it turned out that the root of the problem was a referenced project (a few classes shared between the server and client sides).

Once I removed the project reference and built and included a jar of the once referenced project the problem ceased to exist.

Seems like something went rogue in DDMS 8.0.0 with referenced projects.

like image 6
monsta Avatar answered Nov 09 '22 16:11

monsta


What worked for me was removing the android.jar reference in

Configure Build Path -> Java Build Path -> Libraries

Leave the Android 3.0 library reference.

like image 5
Arunabh Das Avatar answered Nov 09 '22 16:11

Arunabh Das