How to add external libraries to my application in android - 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

Related

how to use Android CardsUI library in Eclipse?

I am trying to use this library http://www.androidviews.net/2012/12/cardsui/. Import, libs folder and external JAR does not work.
This is an Android library project. It is not an app.
You need to attach the Android library project to your app's project. The process for this is detailed in the documentation. Basically, given that you have already imported the library into your Eclipse workspace, you right-click over your app project in the Package Explorer, choose Properties > Android, scroll down to the Libraries section, click the Add button, and choose your imported library.
You cannot just import the jar file for this project because it requires additional resources such as images. Therefore it needs to be imported as a library project

How can I use a project source code as a library for an another project?

I am a beginer in android.My client gave me a project source code(using native libraries) as a refference.Is there any possibilities to use these source code as library for my android project? If it is possible,how can I access methods of these library file? any one please help me..
Import the project into work space. Right click on the project in eclipse. Goto properties. Choose Android. Check if Is Library chexk box is ticked. If not tick the same. This is a library project now.
To refer the library project in your android project.
Right click on the project in eclipse. Goto properties. Choose Android. Click add. Browse the library project and add the same.
Clean and build.
For more information check the link
http://developer.android.com/tools/projects/projects-eclipse.html
Information regarding library project
http://developer.android.com/tools/projects/index.html
If the Android development tools build a project which uses a library project, it also builds the components of the library and adds them to the .apk file of the compiled application.
Therefore a library project can be considered to be a compile-time artifact. A Android library project can contain Java classes, Android components and resources. Only assets are not supported.
To create a library project, set the Mark this project as library flag in the Android project generation wizard.
To use such a library, select the generated project, right-click on it and select properties. On the Android tab add the library project to it.
The library project must declare all its components, e.g. activities, service, etc. via the AndroidManifest.xml file. The application which uses the library must also declare all the used components via the AndroidManifest.xml file.
Other projects can now use this library project. This can also be set via the properties of the corresponding project.
Please check this
To create a library project, set the Mark this project as library flag in the Android project generation wizard.
http://www.vogella.com/articles/AndroidLibraryProjects/article.html

Android app with eclipse project dependency

I have an Android app which uses a jar library generated from another Eclipse project.
But is it possible to directly reference this project instead of using an intermediate jar ?
When I do that, the build succeeds but I get VerifyErrors at runtime saying the classes of my external project can't be found...
Yes, you can directly reference this project by setting it as library. To do so:
Right click on your desired library project, choose properties and mark checkbox 'isLibrary'
Then just simply right click on you project, go to properties and add those library project
Yes, ADT supports libraries in form of shareable source code and resources, not just .jar. Please see Android Developer website, especially Managing Projects -> Library Projects article.

Eclipse will not recognize project as library (ActionBarSherlock/ViewPagerIndicator)

I'm trying to get ActionBarSherlock and the ViewPagerIndicator libraries set up for my projects, but I seem to be running into a few issues. I sent Jake Wharton (The developer) a few messages earlier about it, and got a few replies but couldn't get anywhere - and I think he got busy with a few other things.
What my issue is, For both VPI and ABS
Both libraries open up without any errors, and I'm using compiler version 1.6 for all as is required.
The funny thing is, if I load in the samples that are provided - they work fine and link to his library; but when I go to add the library to my project - the above happens.
Where to store the actual library project does not matter, as long as you use a relative link to reference it. Check out the Library Projects - Development considerations:
Library project storage location
There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as the application project can reference the library project by a relative link. What is important is that the main project can reference the library project through a relative link.
You should always use the Eclipse ADT plugin to select and set up Library Project Reference, i.e. right-click project -> Properties -> Android -> Add, then in the opened Project Selection window, select the Library Project list here (of cause you should import them in the same Eclipse workspace as your Main Project). This will add a android.library.reference using relative path into project.properties as well as show relative path in the Android preference window:
android.library.reference.2=../../../../../Documents and Settings/yorkw/Desktop/JakeWharton-Android-ViewPagerIndicator-f09acb0/library
If you directly alter it using absolute path from project.properties as below:
android.library.reference.1=C:\\Documents and Settings\\yorkw\\Desktop\\JakeWharton-Android-ViewPagerIndicator-f09acb0\\library
Then after Eclipse refresh your project, you get the exact error described in your question, see my screenshot below:
Hope this helps.
While importing the libraries, make sure that you tick the "Copy projects int workspace" check box. The library projects need to be in the same workspace for them to work.
delete and import the project and lib again. build the lib project , add lib to project, still error shows.. rename the lib project. this worked for me ....

Android facebook SDK as JAR

Are there any cons of build the facebook SDK library project into a JAR file(as ADT 16 does with library projects) and adding it to your project? I am not changing anything in the facebook SDK so don't need to have it added as a library project. So far it has been working fine for me and I am wondering whether this is a common practice used by developers using the facebook SDK? It speeds up the build process quite a bit because Eclipse doesn't have to resolve all of the resources in the library projects.
Yes! I just figured it out myself.
You need two jar files:
facebooksdk.jar
android-support-v4.jar
Option 1
The first can be found in the bin folder, the latter in the Android Dependencies folder. (Of the FacebookSDK project)
After adding them both as libraries to my project (Project --> properties --> Java Build Path --> Libraries) it actually worked.
Option 2
Another way is to copy paste the facebooksdk.jar and get the android-support-v4.jar via Right-click on project --> Android Tools --> Add Support Library.
Good luck =)
Kasgoku,
The code is provided as a project for easy viewing of the classes. Adding it as an included jar or just moving the source into your project also works. When I created an FB connected android app, I moved the files I needed into a package in my app.
It looks like maven has them cached.
http://search.maven.org/remotecontent?filepath=com/facebook/android/facebook-android-sdk/4.4.0/facebook-android-sdk-4.4.0-sources.jar
You can create a jar file :
Download Facebook Android SDK from github.
Extract it. (at any location).
In Eclipse create new project using create project from existing source option
Enter the project name as "com_facebook_android".
Set Location to "facebook" folder in extracted location.
Click Finish.
Select the "com_facebook_android" project in project explorer and right click
select export option.
In the export wizard select JAR file in Java folder.
Click next then browse the location for jar file and give the name as yor wish like "facebook-android.jar"
Click finish........ JAR file will be created in that location
Well guys you dont need to manually make a .jar file out of facebook-android-sdk. You can use easyfacebook.jar. It currently supports:
Oauth 2.0 authentication support
Use the access token
Pictures upload support
Supports all the features of Graph API
It can run any query FQL
Contains BEAN of all facebook objects
It's free. LGPL GNU license
Progress dialog
Logout function
Server/Request Error Management
Key hash/Geo Tagging
Login without facebook app

Categories

Resources