Building and including an external module in an Android app - android

I would like to include this plist parser module in my Android application, ideally without just copying the entire module source into my source tree (if that would even work).
I have successfully added the module as a project into Eclipse (3.7.0) and resolved errors by fixing the build path to include Android 2.1, which is what I am using. However, now I'm stuck. All of the information on using external libraries with your Android project I can find expect you to have a JAR of the library, but I only have this source code. I can run the plist parser module as an Android application, which appears to compile an .apk, but that doesn't actually do anything because it's not a standalone application. Any options to just build the module without running it are greyed out in the Eclipse interface.
How can I either build this module into a .jar for inclusion, or include it in some other way?
Edit: In order to clear the errors in the module after I added it to Eclipse, I followed the instructions in this answer.

You can either convert the whole thing to a library project or simply include the source code in your app's project. To create a library project, you can import the project from github, and after you get it compile, remove any activities, go to the project's Properties->Android and check the 'Is a library' check box. Then add it as a dependency to your own project.

Related

Importing android gradle project into eclipse

I need to import this library project into my eclipse. While i am trying to use this project it have some error. Can you help me on this. https://github.com/daimajia/AndroidImageSlider
That project is created for use with Gradle for Android. Eclipse does not support that yet. It is also distributed as an AAR, which Eclipse does not support. There are recipes for converting AARs into Eclipse-friendly Android library projects that you can try. Otherwise, you will need to reorganize the project code yourself to support the classic Eclipse-style project structure. Mostly, that will involve moving the contents of library/src/main/ into a regular Eclipse Android library project:
The res/ directory and AndroidManifest.xml file would go in the library project root directory
The java/ directory would be renamed src/ and also go in the library project directory
However, you will have to repeat this process each and every time the library's author updates the library, at least for those updates that you are interested in.
You may wish to see if there is an alternative library that meets your needs but is better packaged for use with Eclipse.
Basically there are some changes to be done to eclipse project before importing it to eclipse like src folder.
The project you posted may contains many error since it have two more android project dependency.
I tired to convert above project with its dependency :
Checkout Complete Source Code
There is one more project lib u need to add LIB

Build library project

all.
I've created an android library project and it's works perfectly when i reference it from main project. But when i build the library project apart it doesn't contains R.java and resources. Is there way to build a library project with resources and R.java?
It's not possible now.
Now we can create a binary-only library project via the following steps:
Create an Android library project, with your source code and such –
this is your master project, from which you will create a version of
the library project for distribution
Compile the Java source (e.g., ant compile) and turn it into a JAR file
Create a distribution Android library project, with the same
resources as the master library project, but no source code
Put the JAR file in the distribution Android library project's libs/
directory
The resulting distribution Android library project will have everything a
main project will need, just without the source code.
There is some restrictions in this solution:
We still have to ship the resources.
We have to rewrite our code to avoid using R. values, as they
will be wrong. We will have to look up all resource IDs using
getResources().getIdentifier() and/or reflection.
I use Eclipse and never manually build my Android Library Project independently, but I think the development considerations stated on official dev guide here should answer your question:
Each library project creates its own R class
When you build the dependent application project, library projects are compiled and merged with the application project. Each library has its own R class, named according to the library's package name. The R class generated from main project and the library project is created in all the packages that are needed including the main project's package and the libraries' packages.
Update with Another note quoted from the official dev giude Library Projects:
However, a library project differs from an standard Android application project in that you cannot compile it directly to its own .apk and run it on an Android device. Similarly, you cannot export the library project to a self-contained JAR file, as you would do for a true library. Instead, you must compile the library indirectly, by referencing the library in the dependent application and building that application.

Correct way to add android libraries with ADT 14 >

After updating to ADT 14/15 I started having a couple problems with our build.
With one Android based libraries (call it Framework) which is added into the actual android project app (call it App). The Framework project has a couple jar files in its own lib folder which is added to its own build path. Those same jar files are required to be added to the App's build path as well.
So jar files on the Framework build path
Framework/libs roboguice
Framework/libs gson
Those same jar files on the App build path
Framework/libs roboguice
Framework/libs gson
Also the Framework.apk is added via the Android Library panel in the App's project properties.
Both projects are targeting the same Android.
Now when I build the project I seem to have resolved the errors however when running it, at times I receive the Missing Framework.apk in the console window.
So based on this scenario any thoughts on how to correct this build? I have a feeling its still setup incorrectly.
This should help you out!
http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html

android intellij add directory with class files

I am trying to include a library into my android project using IntelliJ IDEA v10.0.3. The .jar library is, however, corrupt, so I want to include the bin directory into the project.
What I am doing: I go to File - Project Structure - Modules - Dependencies - Add - Library - New Library. In the dialog that appears, I give the library a name, then click Attach Classes..., then choose the bin directory. I then click ok.
The library appears to be working fine. I get code completion and use the classes as desired. However, when I run the project, I get the following error:
Error! C:[Path-to-library-project]\bin is a directory. Directory libraries are not supported
What can I do to fix this problem?
Make a valid jar from the required classes and use standard jar library. It's Android specific limitation.

What does checking the "is Library" checkbox do "Under the Cover"?

I noticed that when I convert an existing Android Application project to an Android Library project by checking the "is Library" checkbox, nothing changes in the project's source code or XML files.
So what really happens when the "is Library" checkbox is checked? What changes internally, in the package and/or project files? Where can I learn more about this?
To better explain my question:
What I am interested to know (mainly
for troubleshooting purposes) is
what differentiates an Application package from a Library
package "under the cover"?
Is the fact that a project is
"Library Project" marked
somewhere? If so, where does it
mark it (obviously not in the source
files and not even in the res XML
files)
From the Managing Projects from the Command Line page:
The create lib-project command creates
a standard project structure that
includes preset property that
indicates to the build system that the
project is a library. It does this by
adding this line to the project's
default.properties file:
android.library=true
In other words, it's a property that is utilized by the build system and not by the operating system.
UPDATE: I'm on my iPhone so I won't type out a whole paraphrase, but here's a pretty good blog article discussing the differences between a Java JAR and an Android Library Project, including how the dex tools add the resources and dex code to the .apk:
http://devmaze.wordpress.com/2011/05/22/android-application-android-libraries-and-jar-libraries/
From the devsite: http://developer.android.com/guide/developing/projects/projects-eclipse.html
You can also designate an Android
project as a library project, which
allows it to be shared with other
projects that depend on it. Once an
Android project is designated as a
library project, it cannot be
installed onto a device.
A library project isn't packaged as a seperate redistributable file as you're used to with a jar. It's merged with the the apk file of your application.
The page you linked to mentions it in the Referencing a library project section.
As soon as the Properties dialog closes, Eclipse rebuilds the project, including the contents of the library project.

Categories

Resources