DarkLeafyGreen
DarkLeafyGreen

Reputation: 70466

Importing Class from External Jar, Android

I created a new library and added the jars from web harvester to do a bit of web scraping in my android project. in my main activity I import classes that I need. but starting the project on my phone I get a

08-23 08:28:09.763: ERROR/dalvikvm(2123): Could not find class 'org.webharvest.definition.ScraperConfiguration', referenced from method html.parser.MainActivity.onCreate

any ideas?

Upvotes: 2

Views: 7375

Answers (3)

donald
donald

Reputation: 489

Well, first thing is to check that the library has the right java version. android only support 1.6 and not 1.7 (SDK dependent, but if you want it to work under 2.33, use 1.6) . after that, just drag the file to the libs folder, and select copy. Then, click project properties (right click on the project->properties)-> java build path->libraries tab. in this tab click add JARs and not add external JARs. Select the jar file from your project under the libs folder. If you are still getting the error, make sure your jar file java version is 1.6.

Upvotes: 3

Johnny O
Johnny O

Reputation: 587

I had a problem where a jar was not exported to the apk. I manually edited .classpath and added exported="true" to the classpathentry; seems to have fixed my similar problem.

<classpathentry kind="lib" exported="true" path="lib/gson-1.7.1.jar"/>

Upvotes: 4

Mojo Risin
Mojo Risin

Reputation: 8142

Take a look here http://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary are you placing the jar in subfolder of your project ?

Upvotes: 3

Related Questions