Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Project - Something messed up my .classpath files (Eclipse 4.2? Eclipse 3.8?)

I'm looking if someone else also got this problem, and if he found a source reason for it.

What happened is this:

I have dozens of different project. One of those was this project:

That I had once to help me. I didn't do anything with the project, aside importing it. That was couple months ago. I had Eclipse 3.7 at that point.

In the meantime I found out Eclipse Juno was out, and thought to try it. So I did, but later on due to couple different problems I decided to revert back for the time being. I found out the 3.8 version of Eclipse and so I gave it a go, and left my eclipse environment for a while.

Today I opened Eclipse as I wanted to do some work, and I found out over half of my projects(working projects) stopped working, and gave me this error or some similar errors:

05-18 19:53:01.672: E/AndroidRuntime(3939): FATAL EXCEPTION: main
05-18 19:53:01.672: E/AndroidRuntime(3939): java.lang.RuntimeException: Unable to instantiate activity 
ComponentInfo{com.example.android.bitmapfun/com.example.android.bitmapfun.ui.ImageGridActivity}:

Basicaly errors that had to do with ClassNotFound Exception. I said to myself, that's strange. I started investigating, and after couple of hours I found out something messed up my .classpath (build path) files. I downloaded the sample project again, and it's classpath file looks like so:

<?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 exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

But my .classpath file in my local project looked like that:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

I swear to God I didn't touch that project since I imported it a while back, and it was deffinetly in working condition back then.

Editing Build Path didn't work by itself. Even closing and reopening project didn't help. I had to restart eclipse as well, and only then, when I edited the .classpath file (or build path) it worked again.

Also I found out, that the export tab is not updated. For instance, if I add some library, it is added to dependencies, but in order for it's classes to be found at runtime, it has to be exported. I never (almost never) touched this tab, so it had to be "checked" automaticaly once I added different libraries, but now it seems it's not doing so.

I have no idea what did this, I hope it's not the Eclipse Juno, which had(has) some kind of a bug. Has anybody encountered this?

like image 238
Lucas Avatar asked May 18 '13 21:05

Lucas


People also ask

How do I open a .classpath file in eclipse?

In Eclipse, go to Window > Preferences > Java > Build Path > Classpath Variables. Click New, enter the following information and click OK.

What is the .classpath file?

The . classpath maintains the project's source and target references for Java compilation and compressed file or project dependencies. This configuration is maintained through the Java Build Path page in the project's properties.

Where is the .classpath file?

classpath file is created in the project's root directory.


1 Answers

I went to the complaining library and changed Project-Properties > Java Compiler > Compiler compliance level > 1.6 and that solved my problem.

like image 94
Cote Mounyo Avatar answered Sep 28 '22 16:09

Cote Mounyo