Import java source project into Android project

Can I import an existing Java project that is in my workspace into an Android project that is also in my workspace? The Java project does not use things that are not compatible with Android. I could do this with a .JAR, but since I am modifying the Java project very much, I would like to import all the source code and change it once in a while. Is it possible? Thanks

+6
source share
3 answers

This is a bit of a hack, but worked for my project:

  • Add an Android project and a simple Java project to your workspace
  • Go to Android project properties -> Java Build Path -> Source
  • Click “Link Source” in the “Folder Name”, make sure you select the root directory of the plain tree of the Java src project.
  • Use a descriptive name for "Linked Folder", for example, "java_project_src".
  • Click Finish and compile

This setting will compile simple Java code as Dalvik bytecode. In my case, I had pure Java code with very limited dependencies, but I wanted to share pure Java code with projects other than Android, instead of separately supporting these files in each project.

+4
source

I think you are talking about links to other projects in the current project, if so, then you can do this using Right-click on the project, properties-> Link to project.

+1
source

You can link other projects with your current project. Right click on your main project, select Build Path -> Configure Build Path... In the dialog box, select the Projects tab, then click the Add.. button. Now select the project you want to link and click OK . Now you can use these project sources in your main project. Hope this helps.

0
source

Source: https://habr.com/ru/post/899107/


All Articles