Import source java project in Android project

后端 未结 3 2017
遇见更好的自我
遇见更好的自我 2020-12-17 02:00

Is it possible to import an existing Java project which is in my workspace, in an Android project which is also in my workspace? The Java project doesn\'t use stuff that is

相关标签:
3条回答
  • 2020-12-17 02:42

    I think you are talking about referencing other projects into the current project, if this is the case then you can do this by Right click on project, properties->Project Reference.

    0 讨论(0)
  • 2020-12-17 02:48

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

    1. Add both Android project and plain Java project to workspace
    2. Go to properties for Android project -> Java Build Path -> Source
    3. Click Link Source, in "Folder name", make sure to select the root directory of the plain Java project's src tree
    4. Use a descriptive name for "Linked folder location", like "java_project_src".
    5. Press Finish and compile

    This setup will compile the plain-java code as Dalvik bytecode. In my case, I had pure java code with very limited dependencies, but wanted to share the pure java code with non-Android projects, instead of separately maintaining these files in every project.

    0 讨论(0)
  • 2020-12-17 02:48

    You can link another projects to your current project. Right click on your main project, choose Build Path -> Configure Build Path... In the dialog choose the Projects tab, then click Add.. button. Now choose the project you want to link and click OK. You'll now be able to use this project's sources inside your main project. Hope this helps.

    0 讨论(0)
提交回复
热议问题