views:

1085

answers:

2

Hello. I'm having a problem trying to run an Android app which, up until adding a second external library to its build path, was working fine. Since having added the scoreninja jar, I now get a NoClassDefFoundError when I try to run the app.

Here's the message:

02-11 21:45:26.154: ERROR/AndroidRuntime(3654): java.lang.NoClassDefFoundError: com.scoreninja.adapter.ScoreNinjaAdapter

As all of the build scripts are generated by the Android tools (?), I'm not sure what else I can do other than cleaning and rebuilding or restarting eclipse (I have already tried all three). Does anyone know how I can amend this?

Thanks in advance.

+3  A: 

By adding the external jar into your build path just adds the jar to your package, but it will not be available during runtime.

In order for the jar to be available at runtime, you need to:

  • Put the jar under your assets folder
  • Include this copy of the jar in your build path
  • Go to the export tab on the same popup window
  • Check the box against the newly added jar
Anthony Forloney
ScoreNinjaAdapter is someone else's code, but I would be very surprised if it contained such an error as it is in common usage. The error happens at a point in my own code.
Tom R
Can you post your own code where the error happens?
Anthony Forloney
The error literally just happens here: sna = new ScoreNinjaAdapter(this, SN_APP_ID, SN_APP_KEY);
Tom R
Do you need an `import` statement for external jar files? I have never used them.
Anthony Forloney
Updated my answer, hope this helps.
Anthony Forloney
Thanks for all your help, but I'm still not having any luck with this.
Tom R
Have you tried with the removing the .jar file from the `assests` folder approach?
Anthony Forloney
Yeah. In the end, I got fed up with all this and just downloaded the source and copied the source files into my project. Not the nicest solution, but it works now. Thanks for all your help.
Tom R
I wish we could have found a more permanent solution, good luck.
Anthony Forloney
@Anthony so I can't add another project to mine? I mean, because I can't add the whole project to the assets folder..
Tom Brito
A: 

I'm not sure if this is related, or if you're even still looking for an answer, but I came across this thread while trying to research the same error (but possibly for different reasons).

I couldn't find any solutions online, but an answer on a similar thread got me thinking and realized I probably just needed to rebuild (or clean) the project.

In Eclipse, go to Project => Clean. Select your project and Eclipse seemed to fix it itself. For me this solved the problem.

Hope this helps.

Brian