In Eclipse, Unable to Reference an Android Library Project in Another Android Project

In eclipse, unable to reference an android library project in another android project

OK Here is the solution which I found when I was looking for the default.properies file of the referencing project (not the library) in my file system. Although the referencing project was in the same eclipse workspace as the library project, the actual files were somewhere else in the file system ie they were'nt in the same parent folder of the library project. As soon as I placed the referencing project in the same physical folder as the library project it all went fine.

I guess that this must be something to do with android using ant underneath the covers.

Edit: The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.

Can't reference an Android library into my project

I have resolved to issue by removing eclipse, and reinstalling, seems to be a Eclipse bug when previously using 2 workspaces...

According to this question SO Link

Cannot reference an android library project in Eclipse

To add code as a library, you first need to import it into your Eclipse workspace (right-click your Package Explorer, select 'Import...', 'Android', 'Existing Android code into workspace...'.), and then define it as a 'Library', by selecting 'is library' in that project's properties window.

Project library not getting added to android project

Make sure that your library has the same location with your project source files.
It means that if your source is on your workspace , then your library should add into workspace. If not, you should copy your lib into same folder with source then mount it again.

Eclipse Android project, how to reference library within workspace?


The classical Eclipse/Java way

Add a (workspace) library

  • Right click the project you want to insert in.
  • Click Properties.
  • Select Java Build Path.
  • Select the Libraries tab.

Now, it depends how you compile your library.
So either do an Add JARs... or an Add Class Folder.
Choose the external variant to use an external source.
That's it.

Add a workspace project

  • Right click the project you want to insert in.
  • Click Properties.
  • Select Java Build Path.
  • Select the Projects tab.

Click Add... on the right side and you are done.

The additional Android way

Two steps are necessary:

  • Mark the project you want to use as library project
  • Reference the marked project

Mark the library project

Right click your project and select Properties.
Select Android on the left and tick the checkbox IsLibrary. Done.

Reference the marked project

Right click your project and select Properties.
Select Android on the left and Add... your marked project. It will be added to the list and is ready to use. Now you are able to access all classes and ressources (e.g. drawables, strings) from the referenced, marked project. Awesome, eh? :)

Imported Android project still refers to external libraries but can't find them

A good way to add external JARs to your Android project or any Java project is:

  1. Create a folder called libs in your project's root folder - you already had this
  2. Copy your JAR files to the libs folder
  3. Now right click on the Jar file and then select Build Path > Add to Build
    Path
    , which will create a folder called 'Referenced Libraries' within your
    project

    By doing this, you will not
    lose your libraries
    that are being referenced on your
    hard drive whenever you transfer your project to another computer.

How to add android library project in another android project in eclipse

The porblem was read-only persmissions of files of Project B. I eliminated read-only permissions and it is working now. Thanks for suggestions



Related Topics



Leave a reply



Submit