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 incompatible with Android. I could do it using a .JAR, but since I'm modifying the Java project a lot, I would like to import the whole source code and change it once in a while. Is it possible? Thanks
This is somewhat of a hack, but worked for my project:
Add both Android project and plain Java project to workspace
Go to properties for Android project -> Java Build Path -> Source
Click Link Source, in "Folder name", make sure to select the root directory of the plain Java project's src tree
Use a descriptive name for "Linked folder location", like "java_project_src".
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.
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.
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.
Related
I just downloaded the Android SDK and the plugin but when I try to create a project it automatically makes a library for the support and my project that I created has errors. Here is what I mean:
This is after I clean up the projects [Project -> Clean]
Additionally, R does not work (even when I import it) :
This is all with a clean project. I would appreciate it if you could help me.
Note: I know there are similar questions out there, but I could not get it working.
I think I need to import the appcompat package again, but I do not know where to locate it.
The error the container "Android Dependencies references non existing library" probably means your build path isn't pointing to any jar file. I recommend checking your build path:
Right click and choose 'build path'
Click on 'Android'. Make sure app_compact appears under the library target. If it does not click 'add' under library to add it.
I work with eclipse and I would like to use from external project library some class. Every time I open project properties add this external project I get following problem. There is no problems with another project libraries. This additional project has ticked "Is Library".
I think the best way to import an Android library is :
import your library projects to your workspace
right click your main project and properties
close to the top, choose Android
Then click add from the library section at the bottom
I think the title is very clear. Sometimes I have some build errors, and in the Libraries tab of Java Build Path, I add/remove libraries, etc ... but when I delete the Android X.X "folder", I can't bring it back. What I do is to delete the project from the Workspace and Import it again as Existing Android Project.
Is there a way to add it directly without deleting-importing a project?
How does eclipse generate it? for what purpose? Why if missing eclipse doesn't show errors before building?
Please help me understand all these!
Yes you can do that without removing the project and importing it back.
Right Click your Project-> Java Build Path->Add Library->Android Classpath Container->Choose your Project->Ok
You will your Android X.X back.
Hope it helps.
When you delete your project click on the check box which says Delete projects content on disk and then import your project and to add library go to properties->java build path->order and export and check your library
I have a Java Project in Eclipse, and a Java Dynamic Web Project in Eclipse. In the former, all the jar files are shown individually under the top-level project folder. In the latter, the jar files are under a Libraries folder and the navigation is more convenient.
Is it possible to organize them in the same way in the Java Project also? If so, how?
Update: It is the Project Explorer View. For the Java Project, I see: "my_project_name" with the arrow expanded to point downwards, then I see: "package_icon src/main/java" and below that "package_icon src/main/resources" and then 20 jar files one below the other: "jar_icon activation-1.1.jar", ...
For the Java Dynamic Web Project I see: "my_project_name" as above, then I see: "JAX-WS Web Services" (unexpanded), then "Deployment Descriptor" (unexpanded), then "Java Resources" which I have expandeded, so I see the components of it below, of which the first is: "package_icon src/main/java", then below it, "package_icon src/main/resources", then below it "libraries_icon Libraries" instead of 20 jars! I have the option of expanding Libraries if I really need to see the 20 jars.
The only option I found to make things prettier in Eclipse Kepler is to:
In the Project Explorer window there is a down arrow in the upper right corner. Select that and then Customize View.
Select 'Libraries from external' and then OK.
Kind of cheesy...
EDIT: Of course I had to go and do some more digging...and it looks like I'll have to try this and see how it works.
Similar to M Miller's answer (but for Juno), click Show 'Referenced Libraries' Node in the dropdown of the Package Explorer window:
I'm using:
Eclipse IDE for Java Developers
Version: Juno Release
Build id: 20120614-1722
I noticed this "feature" on Eclipse Juno (latest version), when you have a jar file added to the build path it is not shown as a single file on the project.
Try removing one of the jars from the build path to see if it shows up again.
I couldn't find how to turn it off though.
BTW... the project layout for your "Java Project" is more akin to a "Maven Project", which is a bit more powerful.
You should change into the Package Explorer by Window > show View. It will display all the referenced libraries in a Referenced Libraries folder.
I am developing a study project using the mosembro (mobile semantic browser) project inside my Android project. I am using Eclipse and I created my project, downloaded / imported mosembro and included in my project's build path.
So now my code needs to refer to a resource in the mosembro's project. I want to do something like this:
String commonJS = getScript(R.raw.common);
In this snippet, I want to load a javascript file from mosembro's project: res -> raw -> common.js so I need the java syntax to get "R" (precompiled resource-class) of Mosembro from my HelloGoogle project.
What is the syntax to replace the R-class of this with the included project's R-class.
Is that clear?
I found the answer and it is very simple. You can add projects to your project through the Java Build Path.
Right click on the project you are working on
Select Build Path -> Configure Build Path ...
Then pick the Projects tab
Finally, press the Add... button and select the project that you want to include.
This keeps everything in code-sync if you make changes rather than cut-n'-paste.