Search code examples
javaandroideclipsedependenciesjreddit

Android Using Jar Files


So I'm trying to use the jReddit wrapper class because I am developing a reddit app on the android. Here is what I did:

  1. I first went to jreddit and downloaded as a zip
  2. Then I went to eclipse, made a project and copied the files from the extracted folder into the new project. Here's a picture of what it looks like:
    enter image description here
  3. Then I used the build.xml from here and "Ran as Ant" to create a jar file in the dist folder as you can see above
  4. I made my android project and copied the jar file into the lib folder and built the path. The project looks like this:
    enter image description here
  5. Finally, here is my MainActivity.java. Sorry, I couldn't format the code properly on here

There are no errors, so I can run it on the android. However, when I click the login button to activate the function call onClickBtn, before it can even get into the function it throws an error saying: Could not find class 'im.goel.jreddit.user.User', referenced from method com.example.reddit.MainActivity.onClickBtn

Did I not import this jar in correctly or am i just not using it properly? Why is it compiling fine like it can see the user class but when run on the android it doesn't know what it is?


Solution

  • Extract the contents to the same folder as your other classes. Usually src.

    Or

    Go to project properties (Alt + Enter) and select Java Build Path (Left panel). Then select Libraries (Top middle). Click the Add External JARs button and select your jar.