Posts Tagged ‘error’

Eclipse ADT : Unable to get system library for the project / Conversion to Dalvik format failed with error 1

August 14, 2011 2 comments

Google has provided the ADT plugin for Eclipse which makes the job of creating / testing android applications substantially easier that would have been if we had to use only the command line tools provided with the Android SDK. However I have been facing a strange issue repeatedly for the last couple of days. After restarting my system when I start Eclipse and navigate over to my android project, it shows error as shown in the figure below.

I had no idea as to why this happened. I opened the build path for the project and the message shown there was “Unable to get system library for the project

I tried adding the android.jar manually to the project by clicking on the “Add External Jars” button. After adding the jar and cleaning the project, the errors for java.lang.Object not found did vanish. But another problem appeared. The error was “Conversion to Dalvik format failed with error 1“. I searched the Internet forums far and wide but I guess that the error message that I received was generated a bit too often and under a wide variety of circumstances. I tried cleaning the project, restarting eclipse etc. Finally on a certain forum I found the mention of checking the .classpath file that Eclipse creates. And voila!!  the source of the problem was found !! The below listing shows the .classpath file for the project after adding the android.jar manually through the Eclipse Build Path window.

<!--?xml version="1.0" encoding="UTF-8"?--><?xml version="1.0" encoding="UTF-8"?>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="/media/Data/Development/android-sdk-linux_86/platforms/android-8/android.jar"/>
<classpathentry kind="output" path="bin"/>

I compared this to the entry of a new project that I created in Eclipse which was as follows.

<!--?xml version="1.0" encoding="UTF-8"?--><?xml version="1.0" encoding="UTF-8"?>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path=""/>
<classpathentry kind="output" path="bin"/>

Comparing the two, the solution was easy to identify. I replaced the third line in the .classpath file about the “lib” and replaced it with the corresponding line in the second file.

And it works now !!

As of the time of this writing I have not been able to understand why this happens everytime I restart my eclipse / system and hence I have to replace the classpath entry everytime I start Eclipse. But atleast it works. Hope this helps you. And incase it does, please share it with others.

So after starting eclipse if you see that there are problems relating to java.lang.Object not found, open the .classpath and edit the line as shown above.


Linux Command-line : Some useful Redirection techniques

Redirecting Standard Output
[me@linuxbox ~]$ ls -l /usr/bin > ls-output.txt

Append redirected output to a file instead of overwriting the file from the beginning
[me@linuxbox ~]$ ls -l /usr/bin >> ls-output.txt

Redirecting Standard Error
[me@linuxbox ~]$ ls -l /bin/usr 2> ls-error.txt

Redirecting Standard Output And Standard Error To One File
[me@linuxbox ~]$ ls -l /bin/usr > ls-output.txt 2>&1
[me@linuxbox ~]$ ls -l /bin/usr &> ls-output.txt

Disposing Of Unwanted Output
[me@linuxbox ~]$ ls -l /bin/usr 2> /dev/null