New project, new problems.

Another minor fix you “just need to know”. After some server changes (I moved my SVN installation for one), I decided to just start a new Eclipse project as opposed to ‘fixing’ the old one to the new SVN location.

My basic steps are somewhat like:

  • Make a new Android project with some fake settings
  • Connect to SVN
  • Team->revert the hell out of it

Most of the time this works well.

The problem:

There seems to be a class missing, but there isn’t:
After having all the files, the application still doesn’t work. It compiles and goes to the emulator nicely, but then this happens:

ERROR/AndroidRuntime(287): java.lang.RuntimeException:
Unable to instantiate activity ComponentInfo{packageNameGoesHere}:
              java.lang.ClassNotFoundException:
packageName.ClassName in loader
              dalvik.system.PathClassLoader@44e7a8a8

And:

Caused by: java.lang.ClassNotFoundException:
                   packageName.ClassName in
                   loader dalvik.system.PathClassLoader@44e7a8a8
           at dalvik.system.PathClassLoader.findClass
                   (PathClassLoader.java:243)

No fun at all.
This error is quite obvious: it calls a certain class that cannot be found. In this case it was the class of my main activity. Not a thing that would be easily to miss. It was there in the source of course, no errors in sight, etc, but it still didn’t register as being there. This is of course a warning sign that something is wrong with your building path. But what?

The Solution

For some reason Eclipse had decided that –as opposed to every sane default–  my /src folder didn’t need to be in my build-path. Easily fixed if you this is the problem:

  • Open the build-path (right-mouse on the project -> build-path -> configure build path, or project-properties-> Java Build Path)
  • Click the Source tab.
  • Make sure your /gen and your /src paths are listed there.
  • While you’re at it, if you use google analytics, make sure that libGoogleAnalytics.jar is present in the libraries tab!

3 comments on What do you mean, ClassNotFoundException ?

  1. Memo says:

    Hi i did what you said:

    “Open the build-path (right-mouse on the project -> build-path -> configure build path, or project-properties-> Java Build Path)
    Click the Source tab.
    Make sure your /gen and your /src paths are listed there.”

    The /gen and the /src are their and i still have the same problem.

    Hope you can help me with this problem

    Thanks

  2. ennaN says:

    That could be tricky, it could be loads of things! Is it, just like I had, the main class of your activity, one that should absolutely be there (and maybe even has been)? It could be a “normal” classnotfound, where the class isn’t defined or something like that?

    I would love to help and you could give some extra information here, but if you feel like you’re going to need some explanation with code and stuff, maybe you could head over to StackOverflow? You’d have a wider audience there. Of course, you should leave a link to your question here and I’ll take a look. (if you’re not familiar with SO: it’s not a “forum”, but a question-answer site. They can be a bit harsh on newcomers, but if you show you’ve done some research yourself and ask a clear question, you can get looaads of help there :) )

    But I’m not trying to send you away from here, you could obviously continue discussion here, no problem, but I suspect my comments aren’t really handydandy for leaving code and such :).

  3. Dev says:

    hello what ever saying all is true but it will not working and given unfortunately stop and log cat given filenotFound, nullPointerException.