Cannot Add Library to Android Project in Eclipse - android

I am trying to add a Library to an existing project inside eclipse. I am keeping the Project Folder itself and the Library Folder in a folder marked "ANDROID" on my desktop. When I try to Import > Existing Code into Workspace > Select "ANDROID".. the only project that gets added is the App itself and NOT the library. I even try to add the library on its own and it will show up on the import list but will not have a "ticked box" with the option of "Finish".
I even right clicked my App - Properties > Android > and noticed that the library is there with a red "X" and does not allow me to search for a new library. What am I doing wrong?
This Identical App and library is working with the same version of eclipse for a friend and not me.

Make sure that the libraries and the project are at the same place, i.e.
Copy the libraries in the same folder as your project
Import the libraries (file > Import > Existing Project in workspace)
Open properties of library > Android and select Is Library
Open project properties > Android > Add (library)
Select the library
save the properties
If this does not work for you copy the jar files from its lib folder and paste it in the projects lib. This should only be done if the above method doesn't work

Import Library project in eclipse . Then right click on project and go to properties->Android (Menu on left side) --> At the bottom(below project build target) you will see a check box named is Library Check that box. Now you've made your project a library .
Then in your orignal project where you want to add library go again to to properties->Android (Menu on left side) --> At the bottom(below project build target) Click add button and you will find that library project visible.

This happens when you import the project from some location. If we import some project then it doesn't refer to the supporting library of that workspace. So always check the check box( copy projects to workspace)
Go to file>import project>browse>select a project>Check the copy project into workspace.
Hope it solve the issue.

A late answer, although I thought of giving an in-depth answer to this question.
First switch your folder structure from Android to Project.
Now search for the libs folder inside app - build folder.
Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle
Now you can start using the library in your project.

Related

Android support v7 app cannot be resolved error

I am running eclipse juno on a 64 bit windows 8.1 machine, I have imported a project into eclipse, but the error i am facing is
On reading about it, I came across the solution that I am supposed to configure the build path manually,
but I am unable to do so since,
Please help
In your screen shot I can see app-compact project imported; This should cause your problem. In better word: when you are using app.support.v7 libraries you must import app-compact project in your workspace and add it as your project dependency.
follow below link of developers:
https://developer.android.com/tools/support-library/setup.html
Especially this part will help you:
1- Make sure you have downloaded the Android Support Library using the SDK Manager.
2- Create a library project and ensure the required JAR files are included in the project's build path:
2- Select File > Import.
3- Select Existing Android Code Into Workspace and click Next.
4- Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to /extras/android/support/v7/appcompat/.
5- Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
6- In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
7- Right-click the library project folder and select Build Path > Configure Build Path.
In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
Uncheck Android Dependencies.
Click OK to complete the changes.
You now have a library project for your selected Support Library that you can use with one or more application projects.
Add the library to your application project:
1- In the Project Explorer, right-click your project and select Properties.
2- In the category panel on the left side of the dialog, select Android.
3- In the Library pane, click the Add button.
4- Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
5- In the properties window, click OK.
Update
Also you can import and copy the 'appCompact' library directly to your workspace and then add it as you project dependency. Please follow steps in this guide in order to adding the 'appCompact' by this way:
https://yassirh.com/2014/01/getting-the-android-navigation-drawer-to-work-on-old-versions-of-android/
(The above link is in order to using navigation drawer in older version but same objects are using appCompact and using it have same solution for both)
First of all
Make sure that you've installed already the following libraries Android Support Library, Android Support Repository and Google Repository by checking in the Extra folder by openning the Android SDK Manager in eclipse.
if it is already installed then add them to Eclipse
Eclipse -> Import -> Existing Android Code into workspace.
Add /android/adt-bundle/sdk/extras/android/support/v7/appcompat to your Eclipse workspace.
Right click on the project in Eclipse and select properties.
Select Android -> Library -> Add.
Select appcompatv7 project and Save.
Use import android.support.v7.app.ActionBar to import Action bar in activities and fragments.

Adding library project to PagerSlidingTabStrip

I'm trying to use
Android PagerSlidingTabStrip v1.0.1library
in my project but, after I import the project as existing code in work space I get to project
the Mainactivity and library and and the library is a dependency to the Mainactivity
but it seems that library project doesn't recognized as local library
so what i did is
1- I tried to make a jar file called library.jar from the library project
and I imported as a external jar so that fixed my import but when I try to use PagerSlidingTabStrip object it says missing reference
and beside that there is res folder couldn't be loaded .
2- I follow this How to add a Library Project to a android project
and I did like what the accepted answer said but it still didn't work for me .
This is how I added the library project
That what I got in project libraries
I tried to use this dependency in build.gradle
dependencies {
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
but it didn't work
i added before sherlock to eclipse so when i added it inside the root folder
a bin folder created and inside it there are a jar file and that's
doesn't happen with library so i think here is the problem
any help?
From properties window select option android scroll down, below library heading click the add button and select library project.
I was facing the same issue but soon i came to know that there was support library missing from Library project.
Add support library and clean build the library project and then add it in your project
Do the following:
File->New->Other
Select Android Project
Select "Create Project from existing source"
Click "Browse..." button and navigate to "PagerSlidingTabStrip-master" folder which you have downloaded from https://github.com/astuetz/PagerSlidingTabStrip
Check "library"! (Uncheck "sample"). Make sure "Copy to Workspace" is checked as well.
Click Finish. Now "library" is project in your workspace.
Right-click on your project -> Properties
In Android -> Library section, click "Add"
Select recently added "library" project, click Ok and you're all set.

Android install external library

I want to use this library https://github.com/koush/ion in my project.But I don't understand how can I install it.I am using Windows 8 and Eclipse.How can I install ?
Download that project and put it in workspace of eclipse and import it from work space to eclipse and make it as library project and add it to your project.
Steps to import:
Right Click on package explorer
Import
Existing Project into Workspace
And then browse to the location where the project downloaded
Import it
Steps to add it as library to your project:
Right-click on your project -> Properties
In Android->Library section click Add
Select recently added project -> OK
That's it!
Now you can use it
You must perform the following steps:
Download ion project code.
Import it in your workspace using eclipse.
Right click in your current project and select Properties. The project properties windows must be opened.
Select Android option.
Go to the bottom of this tab and you can view the Library section.
Add the library dependency using the Add button.
I hope that helps!
You are probably better off downloading the jars vs the source.
https://github.com/koush/ion#get-ion
Download those two and place them in the "libs" directory of your project. If that directory does not exist, create it. From with your Eclipse project preferences, you can add those jars as dependencies.

Unable to add library to android project

I am trying to add google play services library to my project. I follow the procedure of adding a library correctly. After adding it properly when I next time check library section in properties it shows red cross in front of added library. I have attached the screenshot also. Any help please?
Make sure that the libraries and the project are at the same place, i.e.
Copy the libraries in the same folder as your project
Import the libraries (file > Import > Existing Project in workspace)
Open properties of library > Android and select Is Library
Open project properties > Android > Add (library)
LSelect the library
save the properties
If this does not work for you copy the jar files from its lib folder and paste it in the projects lib. This should only be done if the above method doesn't work
If project name or path changed,
Select item (red cross marked library project)
Remove.
Add again.

How do you ensure resources (e.g. styles) of a support library project (e.g. android-support-v7-appcompat), are added to your project?

I am trying to implement the actionbarcompat support library project in my android application and I have followed the guidelines here from the android website on how to implement these but the resources of the support library still are not available to my project.
Note: I am able to use methods defined from the compiled classes of the library project, I just don't know how to reference from the styles.
I am using eclipse IDE.
Anybody with an idea how or what I am doing wrong please assist me.
I happen to have found my own mistake! Most certainly I know a few others might go the same path.
These are the steps in adding a support library with resources.
Select File > Import.
Select Existing Android Code Into Workspace and click Next.
Browse to the SDK installation directory and then to the Support Library folder /extras/android/support/v7/appcompat/.
Click Finish to import the project. You should now see a new project titled android-support-v7-appcompat.
In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > add both the
android-support-v4.jar and android-support-v7-appcompat.jar files to
the build path.
6.Right-click the project and select Build Path > Configure Build Path.
7.In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on
this library project. The appcompat project requires you to export
both the android-support-v4.jar and android-support-v7-appcompat.jar
files. Uncheck Android Dependencies.
8.Click OK to complete the changes.
Now You add the library project to your application:
In the Project Explorer, right-click your project and select Properties.
In the Library pane, click Add.
here is where I went wrong. Check if you've done it the right way too (As shown)
Select the library project and click OK. The appcompat project should be listed as android-support-v7-appcompat.
In the properties window, click OK.
Look at the "Adding libraries with resources" section of this document
http://developer.android.com/tools/support-library/setup.html
Basically, you import the resources in a library project called "android-support-v7-appcompat" that you reference in your app project.

Categories

Resources