Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a Library Project to a android project?

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?

like image 819
UpCat Avatar asked Nov 23 '11 19:11

UpCat


People also ask

How do I add a library project to Android Studio?

Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.

What is external libraries in Android Studio?

You are developing an Android app on Android Studio, sometimes you want to use an external library for your project, such as a jar file. Common langs is an java library with open source code which is provided by the Apache, it has utility methods for working with String, numbers, concurrency ...

Can I use Java library in Android?

To use a Java library (JAR file) inside your Android project, you can simple copy the JAR file into the folder called libs in your application. *. jar files in this folder are included into the compile classpath via the default build.

Where is the libs folder in Android Studio?

How to find the libs folder in Android Studio? If you are unable to find the libs folder in Android studio then open your android project in “Project” mode If the project is already opened in the “Android” mode. Then go to Your Project Name > app > libs and right-click on it and paste the downloaded JAR files.


2 Answers

  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

like image 124
Vladimir Avatar answered Sep 21 '22 02:09

Vladimir


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.
like image 41
Kurtis Nusbaum Avatar answered Sep 20 '22 02:09

Kurtis Nusbaum