Just looking for the API docs?
You can find them here.
Droid-Fu - for your Android needs
Droid-Fu is an open-source effort aiming to collect and bundle solutions to common concerns in the development of applications for the Google Android platform. Currently it mostly contains code which I pulled out of Qype Radar, and which I believe may prove useful to other developers. This is very much a work-in-progress, and both content and APIs are still in flux. There is not much documentation (yet), and I intend to change that. For now, you may want to read all related articles on my weblog. You can also find me on Twitter.
What does it offer?
Droid-Fu offers both support classes meant to be used alongside existing Android code, as well as self-contained, ready-to-be-used components like new adapters and widgets.
The areas tackled by Droid-Fu include:
- application life-cycle helpers
- support classes for handling Intents and diagnostics
- better support for background tasks
- super-easy and robust HTTP messaging
- (remote) image handling and caching
- custom adapters and views
I suggest you read this introductory article, and anything that follows.
How do I install it?
Droid-Fu is deployed as a JAR. Just drop it in your app's lib folder and add it to the classpath.
Getting the JAR
You can get the Droid-Fu JAR in several ways.
The easiest one is probably to download a pre-built version from GitHub. Just know that these builds may not contain the most recent changes you see in the master branch.
If you want to stay on the bleeding edge, you must download the sources and roll the JAR yourself. It's a little elaborate, but don't run off scared. Just follow these steps and you'll be fine. Droid-Fu employs a managed build process, driven by the wonderful Maven build system system. This means you have to install both Maven (v2.2.1 or newer), and the maven-android SDK deployer. Droid-Fu is currently built against the Android 1.5 R3 APIs, so you must have the proper Android JAR installed, too. Consult the Android SDK docs to learn about how to download and install different Android platform versions using the AVD/SDK Manager bundled with the ADT.
Step 1: Getting the source codes
If you're using git, do a
git clone git://github.com/kaeppler/droid-fu.git
git clone git://github.com/mosabua/maven-android-sdk-deployer.git
Step 2: Install the Android JAR to your local Maven repository
Droid-Fu must be compiled against the Android 1.5 R3 JAR. Since the build is driven by Maven, we must provide the Android JAR to Maven during the compile stage, otherwise the build will fail. Change to the folder to which you downloaded the maven-android SDK deployer source code, and into the platforms/android-1.5 sub-directory, e.g.:
$ cd ~/projects/maven-android-sdk-deployer/platforms/android-3
Legacy Android SDK Platform Folder Issues
When you cloned the
maven-android-sdk-deployer, you will see folders that look like this:
android-3 android-4 android-7 android-8 ...
If you have installed SDK's previous to a SDK tool update (Spring 2010), your Android SDK platform folder structure may look like this:
android-1.1 android-1.5 ... android-2.1
This does not match what
maven-android-sdk-deployer is expecting. The pom.xml file in the
android-3 directory in the
maven-android-sdk-deployer has a setting which it uses as the artifact id. This artifact id is set to
android-3 . This needs to match the Android SDK platform folder. To get this to work, you have two options:
Change the artifactId in the
maven-android-sdk-deployer pom.xml file.
maven-android-sdk-deployer directory, go into the
android-3, open the pom.xml file and change:
Go into your Android SDK, delete all the platforms and re-install them using hte SDK Setup tool (SDK Setup.exe). This will recreate the platforms with the correct folder structure / naming.
End Legacy Comments
Now install the Android JAR with:
$ mvn install -Dandroid.sdk.path=/path/to/your/android/sdk/root
If the build fails, you probably provided a wrong SDK root. An
ls in the
android.sdk.path should list (among other files) a
Example: I have installed my Android SDK into
C:\SDK\ . My
mvn install ... looks like this:
mvn install -Dandroid.sdk.path=C:\SDK\android-sdk-windows\
Step 3: Build and install the Droid-Fu JAR
Note: You will need the Java SDK installed, not just the JRE
If you just want to build the JAR, and copy it around manually, change to the folder where you downloaded/cloned the Droid-Fu sources, and run:
$ mvn package
This will build the JAR and place it under the
target directory. To make your life easier, I included a switch which lets you deploy the JAR directly to your application's lib folder:
$ mvn install -DcopyTo=/path/to/your/apps/lib/folder
This will build the JAR and copy it to the given folder.
If you want a JavaDoc JAR to get inline docs in Eclipse, do this:
$ mvn javadoc:jar
This will create a JavaDoc JAR under
How do I use it?
Link the JAR to your application's classpath, as you would with any other JAR in any other Java or Android project.
If you haven't yet created an Application class for your app, create a new class and let it inherit from
com.github.droidfu.DroidFuApplication. Otherwise, just alter your app class to include said inheritance relation.
If you had to create a new app class in the previous step, modify your
AndroidManifest.xmland change the
applicationelement so that its
android:nameattribute points to the name of the new class, e.g.:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" ...> <application android:name="MyApplication" ...> ... </application> ... </manifest>
How is it licensed?
Droid-Fu is free and open source and may be used under the terms of the Apache License, Version 2.0.