tags:

views:

185

answers:

2

My Android project references external classfiles that are not included in the in the Android SDK. I added those classes as an external library properly in eclipse. The code compiles with no problem. But as I try to run the application I get an ClassNotFoundException by the DalvikVM, although all the neccessary classes have been ported.

Am I missing something?

The steps I did.

  1. create new folder in eclipse android project.
  2. copy neccessary classes in this folder.
  3. add the folder to the classpath via eclipse.
  4. programm
  5. compile
  6. run as android application
  7. --> Exception

EDIT:

I tried to add the external jar now. I get the following errors when eclipse is rebuilding the build path:

"warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.)"

That comes for every class file in the jar apparently.

and: "Dex Loader]Unable to execute dex: null" and: "Conversion to Dalvik format failed: Unable to execute dex: null"

+1  A: 

right click and go to Properties of your project.

select Java Build Path-->libraries-->add external class folder(which contains your class files.)--> Ok. that it. hope it helps.

Praveen Chandrasekaran
I already did that. It's not working.
check whether you import the package on your java code.. after that you will get error then post your Logcat error in your Question...
Praveen Chandrasekaran
+1  A: 

The Android Development Tools (ADT) - I assume you're using this to build your project - will only pick-up external jars that are located in the "libs" folder of your Android project. Otherwise, they won't get picked up and converted to Dalvik bytecode and added to your classes.dex file:

http://mylifewithandroid.blogspot.com/2010/01/jars-on-classpath.html

Unfortunately, it won't add classes that you just add to your Java project build path.

Ricardo Gladwell