I have downloaded a messaging framework library from eneter.net. In eclipse I have imported the library to the /libs folder. I right clicked on the library and then added it to the build path. I know that the code is right, but when I compile it and try to run it, it says that that it can't find the classes. Odd thing is when I open up the apk in a zipping program, the library wasn't added to the apk at compile time. Does anyone know why this would be?
3 Answers
Try right-clicking your project in Eclipse's project explorer, then hit Properties
. Go to the tab labeled Java Build Path
and hit Add Library...
(or if it is a jar file, Add JARs...
if you already added the Jar to your project and Add External JARs...
if it is not yet within the project). From there, browse for the library you wish to add and add it to the project. Re-compile (maybe even Project->Clean) and try running it, and see if the library gets added now.

- 10,678
- 16
- 57
- 76
-
does it matter if it's just an external jar file? When I click add library... it brings up a list of choices of why type of library it is, none of those apply. It's just a JAR that I want to add to my project – Andrew Butler Jun 01 '12 at 16:55
-
Yes, you can add jars here. You probably want to click `Add JARs...` instead though, in that case. That's actually exactly what I have in one of my apps, and it works fine. – Mxyk Jun 01 '12 at 16:56
-
@MikeGates: Your instructions have been out of date since the R17 edition of the ADT plugin for Eclipse. – CommonsWare Jun 01 '12 at 16:57
-
I guess it would have helped if I read the changelog haha . Thanks guys! It was because I named the folder the library was in 'lib' and not 'libs'. – Andrew Butler Jun 01 '12 at 17:28
I right clicked on the library and then added it to the build path
That is not necessary, as of the R17 version of the ADT plugin in Eclipse. Moreover, it may cause problems if you do it.
Does anyone know why this would be?
Possibly because there is a typo in your directory name, such that it is not named libs/
. By adding it manually to your build path, you are compiling against it, but the build tools are not adding it to the APK.

- 986,068
- 189
- 2,389
- 2,491
Is the library in the form of a complete Android project? This is then used with another Android project by going to the Properties of that project, selecting the Android tab, and then finding and selecting that library in the lower window.

- 10,903
- 5
- 61
- 84