After uploading 2 casual gaming titles(Powered By And Engine: http://www.andengine.org/) on the Android Market(Search: Lunar Monk), We at Lunar Monk have been digging into the internals of the Android Graphics and Gaming capabilities(And Engine is good for your basic first game, but native is better). Our adventure begins from Replica Island (http://replicaisland.net/), One of the early games written for Android by Chris Pruett, which is open-source (http://code.google.com/p/replicaisland/) too. A read only copy can be checked out using Cygwin by giving the following command on Cygwin Bash,

svn checkout http://replicaisland.googlecode.com/svn/trunk/ replicaisland-read-only
 Just Make sure you have the svn package installed with Cygwin.
Our next step is building the Source, which is a bit of a daunting task due to this error: Conversion to Dalvik format failed with error 1. Let’s see how to eliminate this error.
First thing first, the source which is checked out is setup to be built on android 1.5 and as most of us know that there are not much of those android versions alive today, So we chose to build on android 4.0. But if we are configuring the project in Eclipse, then it is easy to spot that it fails to create R.java, which is due to the 2 anim files  activity_fade_in.xml & activity_fade_out.xml. Both the files use a linear interpolater for animation which is internal to android. To fix this, we need to create another xml with name linear_interpolator.xml. The contents of this xml would be,

<?xml version=”1.0″ encoding=”utf-8″?>
<linearInterpolator xmlns:android=”http://schemas.android.com/apk/res/android”/&gt;

Moving further we would be linking this xml to our activity_fade_in.xml & activity_fade_out.xml by changing the android:interpolator entry in these two files to, android:interpolator=”@anim/linear_interpolator”.Now cleaning the project and rebuilding it would result in successful compilation, but an attempt to install it on a device will result in the dreaded Conversion to Dalvik format failed with error 1. This is due to the fact because the compiler is confused due to the multiple entries/pointers to few classes being linked from different places in this project which is resulting in a path as well as name space conflict. To fix this, We need to first remove all the other jars included in Replica Island except the android.jar(Can be done by Right Click the Project -> Properties -> Java Build Path). Now we need to open the classpath file present in the project directory and replace its contents by,
<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”src”/>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”output” path=”bin”/>
</classpath>

Cleaning the project and rebuilding it now should fix the bug now.

However, If the dreaded error is seen again then this might be the cause(the fix is provided too): http://stackoverflow.com/questions/6683955/conversion-to-dalvik-format-failed-with-error-1-solution

Advertisements