views:

195

answers:

2

Hi,

As part of the Android application I am developing in eclipse, I need to combine two packages from different projects into a single project. I tried copying the files in the package of the second project under the src folder of the first folder and copied other files required for second package into the res folder of the first project.

But the auto-generated Java files i.e R.java doesn't get updated on copying. I tried right clicking on the project and clicking on Android Tools -> Fix Project Properties. But nothing changed.

Any pointers on what I am doing wrong would be much appreciated.

+3  A: 

I would rather add a second source directory through a linked folder.
(Especially since they now support relative path (3.5), as the following picture illustrates (3.6 only)

alt text)


Another solution is simply to add the second project in the "Project dependencies" of the first.

alt text

VonC
So its impossible to make it a single project I suppose..
primalpop
@primal: you could make one single project, by referencing both `src` folder of the other two projects through linked folder. That means re-creating all the right settings (classpath, library dependencies, ...) though.
VonC
A: 

You shouldn't have to resort to importing or cross-referencing projects.

As far as I am aware, the R.java file is generated from the XML files in res.

Specifically, it is created based on the "id" in layouts and "name" in the strings.xml file. (There are probably other things that do it, but this is what I know).

Perhaps, when copying your files, your ids are not formatted with the "+" that encourages the values to be created if they do not already exist.

For example, a TextView in a layout would contain:

<TextView
   android:id="@+id/author"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
/>

The plus there is crucial to new creation of values.

It may also help to put a basic edit into an xml file, save it, then undo the edit and save again. The saving may trigger the Eclipse plug-in to regenerate the R.java file.

HXCaine