Can't compile with Android Library Projects - android

I have two Android Library Projects in Eclipse (yes, "Is library" is selected in both of them).
One of those is ActionBarSherlock, the other one is ViewPagerIndicator
Now, ViewPagerIndicator must include ActionBarSherlock as a library dependence, so I add it under the "Android" settings of the project. Problem is, in the moment I add the library dependence, if I go to Java Build Path of the same project I can see that the dependence .jar of the added library is required but not present (of course, as it is a library project, no jars are created!).
What can be the problem? Furthermore, I have to add both libraries as dependences to an Android application, which presents the same issue.

Are you using ADT14? If so, you probably need to migrate the library projects to the new structure. Right click the library project and select 'Fix project properties' from the Android tools menu.

Related

How to add an android library to an eclipse project without checking it out in the workspace?

I have a project that has multiple android libraries mentioned as dependencies. Is there a need to add all the libraries to Eclipse workspace for building the project? Is there a way to avoid that?
There is the absolute need to have them when compiling your android project. Otherwise you would get compile errors because of missing classes. You have two options here
Have the library project in your workspace and reference it (like you mentioned).
Create a jar from each of the library projects and add those to your application. This way you won't need the library project in your workspace.
It depends on the kind of library which way you should choose. If the library is changed often and you have direct access to the sources I would import the project. If you're afraid to lose the clarity in your workspace you can use working sets to hide the library projects.

Including External Library in Android project

I am new to android I thought of using this Opensource library but I don't know how to download it and include it in my project since there is not .jar file.
Set the library up as an Android library:
Right-click on the library project
Select Properties
Go to the Android tab
Mark the project as the library
Then set your application to use the library:
Right-click on the library project
Select Properties
Go to the Android tab
Add a library at the bottom
That way, you will now be using the library when working on your app.

Issue with importing slidingmenu into an existing eclipse project

I imported the library into eclipse by going to File>Import>Existing android Code> etc
and now i have an extra project called "library" in my workspace
Then I right clicked on the project i want to implement this library to and clicked properties, added the library project, as shown in the screenshot below. But when I click Apply/Ok i get a jar dependency error, does anyone know how I can properly use the slidingmenu library in my app? Thanks
Jar mismatches are usually due to the support v4 library jar file being in both your project and the library. To fix this, make sure the entire project and its libraries has 1 copy of the jar by deleting any others. Afterwards, reference that one copy by right clicking your project and adding that copy as an external archive.

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

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

Categories

Resources