Reputation: 11
Currently I have a working android project1 developed in Eclipse, it contains 2 packages, say package A and package B. I am developing a new android application which I can reuse the package B source code without any modification. I have tried to copy the package B src directory into the project2 src code directory directly. when I start the App, I am getting error on "Link of class in package B prject1 failed". Is this the correct way to reuse existing code, or is there a better way to accomplishing this task? Thanks in advance...
To summarize:
project 1: package A and package B.
project 2: package C and package B.
Need to move package B src code into project 2.
Upvotes: 1
Views: 727
Reputation: 12717
If you need to share package B between Project 1 and 2. I suggest you to create a library project.
to creata library project.
mark it as Library
After creating library project, then you can add them to your Project 1 and 2
Right click project name
add library project
as you see below image universal-image-loader is a library and i can add it to my projecy
Upvotes: 3
Reputation: 2800
In Eclipse's Project Explorer (Select Window > Show View > Show Project Explorer if not enabled), you should be able to right click your project and select Import. The import dialog will give you the ability to select the root directory. Here you can select the root directory of your package B source code.
I believe (I could be mistaken) this will actually cause the source code to be duplicated and placed in the new workspace. While this isn't the end of the world, it's not exactly space-efficient. I'm sure someone else may have a more practical solution.
Alternatively (just searched your question on stackoverlfow for duplicates), you could import the existing project to the build path of your new project: import from another java project in eclipse.
Upvotes: 0