2

I'm trying to use the cwac-loaderex library in my Android application. I cloned the repository and have imported the included project into my Eclipse project.

At this point I don't have any compilation errors in Eclipse, but when I try to run the application in the emulator I get:

03-23 20:34:16.895: E/dalvikvm(652): Could not find class 'com.commonsware.cwac.loaderex.SQLiteCursorLoader', referenced from method com.alwaysorderdessert.AlwaysOrderDessertActivity.onCreateLoader

How do I make sure that these external dependencies are loaded along with my application in the emulator and are also (by extension?) included in my distributed .apk?

Thanks!


Update

I have added the .jar file to my project and included in the build path, so now my project explorer window looks like the following:

project explorer snippet

However, I'm still getting the same error in the emulator. Any ideas?

Thanks again.

Update 2

After a bit of Googling and thanks to this SO answer I found that I just needed to check off the .jar file in the Java Build Path > Order and Exports tab.

Order-Export snippet

Update 3

As was pointed out by the comment in the answer below, I should have copied the .jar file to the libs/ directory rather than lib/. This makes the other changes unnecessary (i.e., adding the .jar to the build path, selecting it for export). What a difference a letter makes!

Community
  • 1
  • 1
Eugene S
  • 3,092
  • 18
  • 34

1 Answers1

2

Put the JAR in your libs/ directory, and that should be sufficient.

I noticed that my README was out of date, telling you to add it to your Eclipse build path. That was correct a year-and-change ago but is no longer needed and may contribute to your problems. Hence, if you manually adjusted your build path, undo that. I apologize for the stale instructions.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thank you for helping here. I tried your suggestion, but it didn't resolve my issue (see above). Would love for you to take a second look. – Eugene S Mar 24 '13 at 15:31
  • Hi, I was able to find the last bit I needed to do to make it work (see above). It might be just a newb issue, but if you're going to update the README I this step should be added to the documentation. If you edit your answer to include this last step, I'll give it the check. Thanks. – Eugene S Mar 24 '13 at 15:38
  • @unluddite: Rename your `lib/` directory to `libs/` -- as was in the README and in my answer -- and remove all manual modifications to your build path (including your "Update 2"). – CommonsWare Mar 24 '13 at 15:53
  • whoops! What a difference a letter makes! My apologies. – Eugene S Mar 24 '13 at 16:02
  • 1
    @unluddite: Yeah, `libs/` is the magic JAR directory. Its contents are automatically added to your build path at compile time, and its contents are automatically poured into the APK for distribution to devices. – CommonsWare Mar 24 '13 at 16:06