Skip to content Skip to sidebar Skip to footer

How To Import .java From Another Project And Package In Android

We're working on a project (Project A) in college that has to extend from a class that is another project (Project B), made years ago. This is working under Eclipse, and developing

Solution 1:

What you can do if you have the complete project B that you need to include inside your project (project A).

  1. Make Project B a library in the following manner :
    • Right click the project B in Eclipse, and click on Properties.
    • Select Android then the isLibrary check box. Project B Properties
  2. Once Project B is a library, you have to add the library B (formerly project B) in your project A in the following manner :
    • Right click the project A in Eclipse, and click on Properties.
    • Select Android then click on Add.... Add Library
    • You should see a list with all the library projects inside eclipse on your machine. You should also see Project B. Select it and click OK. Library Selection
    • You should see Project B in the list of libraries. Project B added as Library

Now you should be able to import packages from Project B to project A and use its classes with no problem.

Solution 2:

Try reference projectB in projectA as follows:

  1. Open "Properties" window of projectA
  2. Go to "Android" Tab
  3. Click "Add" button in the "Library"
  4. Select projectB as reference

After this you can import class from projectB.

Post a Comment for "How To Import .java From Another Project And Package In Android"