0

I have a Java Project that carries out Mechanical Turk HIT Tasks and I would like to use this within an Android app. I tried to write the MTurk functions within my android app, but I couldn't get it to work due to some errors related to the sdk jars. In short I have an Android App Project and a java Project. is there any way I can use the java project within my android project ?

1 Answer 1

3
  1. You can export your java project as a jar, and add to other projects I think. (project-> right click -> export -> java -> jar files in eclipse). Add this jar files to lib folder in android project.
  2. If your java project doesn't have other dependancies, you can copy the source, with the full package, into your android project and reference it. It worked sometimes for me and sometimes doesn't. I think it is because the java project uses packages that is not present in android.
  3. Another way, but I never tried it. Right click your android project, choose Build path -> Configure Build path. In the resultant dialog, select Projects tab and click Add. Now select the project you want to link and click OK.

This question may not give a direct answer, but might help.

Sign up to request clarification or add additional context in comments.

7 Comments

So I've added the jar file. How do I use methods within that jar file ?
I'm sorry but I'm a bit confused. In my java Project I have class called MTurkClass and I exported my java project into a jar called turk.jar . So how do I access the methods in the class MTurkClass ?
First put the turk.jar into libs folder in your android project. If there is no folder named libs, create it and add. Make sure to reload your project in eclipse (project -> right click -> Refresh) after adding folder and jar.
Then in your android project, import MTurkClass with the full java package name. Remember not the package name of your android project, but the package name of original java project. And then you can use that class, if everything goes right
I've already added the jar file to the build path. The question now is how do i use the methods within that jar ? I tried import turk.MTurkClass, but that gives me a comoiler error
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.