Android Activity ClassNotFoundException - tried everything

I spent some time play with my own project, and I am able to replicate your problem and get exactly the same exception stack trace when trying to run my main project, so I think this could be the cause:

Just like what I thought, it is all about how you reference your Android library project in the Android main project, a simple Eclipse configuration settings.

The Wrong Way:
Right click main project, choose Properties -> Java Build Path -> Projects -> Add..., this add the Android library Project as a dependency project in Android main project's build path, this does not work. If all required Android-related resources are defined in main project, you will not get any error at compile time, but when run the application, you get the exception described in the question.

The Correct Way:
Right click main project, choose Properties -> Android, in the Library section, add your Android library project here. Check out official dev guide Referencing a library project. This should fix all your problem. Also note that you have to use relative path reference the actual Android library project, as stated in the Library Project - Development considerations.

Hope this helps.


i've tested the code that you've given , and it works fine. try changing the "extends SimonSaysActivity " to simply "extends Activity " and see for yourself that it works .

the reason that it doesn't work is either SimonSaysActivity doesn't extend Activity (which i don't think you've made this mistake) , or the order of the build path is wrong .

to go to the order of the build path , go to :

project->properties->Java build path->order and export .

my basic order is : project src , project gen , android 4.0.3 , android dependencies .

this problem usually occurs when you use libraries .