53

I have created a new android project. I want to have a action bar at the top so I downloaded the Action Bar for Android Library because I want to support devices from android 2.1.

The description says

The action bar component is an Library Project. This means that there's no need to copy-paste resources into your own project, simply add the action bar component as a reference to any project.

I am new to android so what does this mean? How can I add the library to my existing project?

Import the library into your eclipse workspace:

  • File->Import->General->Existing Projects into Workspace, Next

  • Select root directory: /path/to/project

  • Projects->Select All

At this point it fails because there is nothing to select and the next button is deactivated.

Any ideas?

Mr_and_Mrs_D
  • 27,070
  • 30
  • 156
  • 325
Upvote
  • 65,847
  • 122
  • 353
  • 577

3 Answers3

120
  1. File->New->Other
  2. Select Android Project
  3. Select "Create Project from existing source"
  4. Click "Browse..." button and navigate to johannilsson-android-actionbar\actionbar
  5. Finish (Now action bar project in your workspace)
  6. Right-click on your project -> Properties
  7. In Android->Library section click Add
  8. select recently added project -> Ok
  9. that's it!

Now you can use it

Vladimir
  • 3,644
  • 3
  • 22
  • 26
  • 8
    But now you have to have the library project open in your workspace any time you want to work on the dependent project right? Isn't that awkward? – David Doria Sep 09 '13 at 15:06
  • 3
    if your library project doesn't appear in the `Android->Library->Add` list, go to `Android->Library` of your library project, and make sure "is Library" is checked – woojoo666 Sep 04 '14 at 00:21
  • 1
    also be sure that library has a check in Properties isLibrary=checked – AndroidGeek Nov 24 '14 at 07:08
9

Checkout this documentation on how to reference a library project in eclipse.

From the link above:

  1. In the Package Explorer, right-click the dependent project and select Properties.
  2. In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
  3. Click Add to open the Project Selection dialog.
  4. From the list of available library projects, select a project and click OK.
  5. When the dialog closes, click Apply in the Properties window.
  6. Click OK to close the Properties window.
Kurtis Nusbaum
  • 28,683
  • 10
  • 69
  • 97
  • 3
    at 4 the dialog is empty, there is no library listed – Upvote Nov 23 '11 at 20:03
  • you have to import the library into your eclipse workspace first. See this post for how to do that: http://stackoverflow.com/questions/2231474/how-to-import-existing-android-project-into-eclipse – Kurtis Nusbaum Nov 23 '11 at 20:40
  • i am having same problem as artworkad mentioned but Kurtis i tried ur way and its still showing me nothing – Uahmed Apr 15 '13 at 07:56
1

Plus to the "best answer", at step 8, if you don't see the project, go to the project what you would like to add as a library and

  • open 'project.properties'
  • add 'android.library=true'

and you can again follow the instruction and you should see the desirable project.

zubroid
  • 61
  • 8