Unable to add library to android project - android

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.

Related

Building a project on Eclipse didn't output any bin/*.jar file

downloaded the following open source.
https://github.com/umano/AndroidSlidingUpPanel
Import /library to Eclipse as a Existing Android Code.
There's no error after building the project.
I would like to add the library to my developing app. So I guess I have to build it successfully with library.jar being output to /bin. Or is there other way to make dependency between them ?
You should set the AndroidSlidingUpPanel project as library project. After doing that, in eclipse, right click on your project in which you want to add the AndroidSlidingUpPanel project and go to properties. Then go to android section. In the bottom, click on add Library and select the project. You don't need to add jar manually, eclipse will do that for you.

Android: cannot import BaseGameUtils successfully in Eclipse

I want to use game api in my android project.
And I get started by following the instructions described in Google Site
(the part - Setting up your game project) from the following link.
https://developers.google.com/games/services/android/init
I have downloaded the library BaseGameUtils from this link
https://github.com/playgameservices/android-samples
Then I import it as a project as described in instruction.
However, what I've got is a project named main but not BaseGameUtils.
And then I cannot called its BaseGameActivity in my android project.
How can I solve it?
Same issue solved differently.
I've imported the BaseGameUtils project and also couldn't refer to it.
If you right-click the BaseGameUtils project that you've just imported and then go to properties > android and check "is library" you are able to refer to it in your app project.
Solved.
When importing project, not to select BaseGameUtils folder, but the root folder 'android-samples-master'. Then check the project named BaseGameUtils.
This worked for me:
Download code from github, https://github.com/playgameservices/android-basic-samples
In the downloaded folder copy the files from
android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\src\main\java
to
android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\src\main\src
Now import android-basic-samples-master as an android project.
Choose only BaseGameUtils , you'll get a project called main, right click project > properties > android
Add library and select google-play-services_lib and also tick isLibrary and OK.
Also add an external jar android-support-v4.jar by right clicking project > properties > Java Build Path > Add external Jar .
Now add this project named main to your actual project as a library. TADA !
SOLVED.
You must follow: From the command line run Scripts/make_eclipse_compat (or Scripts/make_eclipse_compat.cmd on Windows). This creates the directory structure needed to import the projects correctly.
Attention: android-basic-samples-master > Script/make_eclipse_compat.cmd
Ref: https://github.com/playgameservices/android-basic-samples
Adding to SEG.Veenstra's answer "....just imported and then go to properties > android and check "is library" you are able to refer to it in your app project" this link as there are problems in Google's documentation: Android Play Services Leaderboard cannot be installed (BaseGameUtils)
This is the original Directory structure from this playgameservices github link
android-basic-samples->BasicSamples->libraries->BaseGameUtils->
Change your BaseGameUtils project directory structure to this:
Now try importing this BaseGameUtils project into your Eclipse workspace.
Right Click on BaseGameUtils project->properties->Android->Check Is Library
Right Click on "YourProject"->properties->Android->Add->BaseGameUtils
Apply & OK.
Now BaseGameUtils is linked with your project

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.

How to add external libraries to my application in android

I have an application that I have to look at as a training exercise. It has used few external libraries such as SlidingMenu, ImageViewZoom and ActionbarSherlock.
I have downloaded and extracted those libraries but I have no idea how to add them to my existing project.
For those that are distributed as a simple JAR, do what Emil Adz indicates, and copy that JAR into your project's libs/ directory.
For those, like ActionBarSherlock, that are distribute as Android library projects, you will need to do a bit more work. In the case of Eclipse, you will need to import the library project into your workspace, then go into Project > Properties > Android for your application project and click the [Add] button to add the library project to the application project. For a command-line build, use android update lib-project to link the application and library project together.
You can read more about referencing an Android library project from Eclipse or the command line in the documentation.
You need to import those libraries as Android Project from existing source and mark them as "Is Library" by going into their properties.
Once you marked it as "Is Library" add it to your
project by going into Properties->Android->Library->Add (it will show the list of library you imported).
The Right Way:
What you need to do is to copy the external library (JAR file) to the /libs folder of your project.
That way those libraries will compile with your project and could be use on real device when you deploy your application.
Some times you will need to add a project to your workspace ( For example the Google Map library)
and then add the library reference using the properites -> Android window at the bottom.
You can get an idea of how it's done by reading the first 3 step of this Google Map API V2 guide I wrote. there I reference the android library project:
Google Map API V2 Guide
The Wrong Way:
any other way, like for example adding the files using the properties - > Java build path screen may result in a missing library when you run the project on a real device.
if they are jars the make a libs folder then paste the jar in it and then go to your project buildpath->configure build path->Add Jars-> ok and if it is a library project then go to your project Property->Android->Add(Your Lib Project)->Ok->Apply

Cannot Add Library to Android Project in Eclipse

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.

Categories

Resources