Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining packages from different projects into a single project in eclipse

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.

like image 239
Primal Pappachan Avatar asked Oct 14 '22 05:10

Primal Pappachan


2 Answers

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 http://img411.imageshack.us/img411/1299/dynamicpathvariables.png)


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

alt text http://img24.imageshack.us/img24/9511/eclipsebuildpath.png

like image 150
VonC Avatar answered Nov 15 '22 13:11

VonC


I ran into difficulties with VonC's method producing force-close noclassdeffounderror at run-time since referencing the external project doesn't make the class available run-time. Perhaps I was not doing it correctly, but I found a different solution to share:

Put both projects that you need to combine into the same workspace and open both. Set one project as a library, and reference the library in the other "main" project, as shown in: http://developer.android.com/guide/developing/projects/projects-eclipse.html

Don't forget to declare any applications you use from the library project in the main project's manifest.

like image 28
cstricklan Avatar answered Nov 15 '22 12:11

cstricklan