for Google Android

Getting Started

The code produced by this tutorial is located at


Transfuse requires a Java 6 (or greater) JDK and the Android SDK.

Create an Android Project

Use the Maven archetype to run a new Android project, creating a basic Android application:

mvn archetype:generate \
  -DarchetypeArtifactId=android-quickstart \ \
  -DarchetypeVersion=1.0.10 \
  -DgroupId=org.androidtransfuse \

Remove the generated Activity class ( as well as the Application entry in the AndroidManifest.xml.

The AndroidManifest.xml should look like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
package="org.androidtransfuse" android:versionCode="1" android:versionName="1.0-SNAPSHOT">

Transfuse will add the Application xml back and manage it for the user. Transfuse is legacy friendly and gives the user the ability to migrate Activities and other Android components into Transfuse as needed. For applications with an existing codebase the step above is not required, but some manual merging may be needed.

Download Transfuse

Add the transfuse dependencies into the Maven pom:


Transfuse also can be downloaded directly from Maven Central.

The only runtime requirement for Transfuse is the API library.


To build a Transfuse Activity, update the default layout (main.xml) in the res/layout folder:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
    <TextView xmlns:android=""

And the accompanying Transfuse Activity:

// Example Transfuse Activity
@Activity(label = "@string/app_name")
        @Intent(type = IntentType.ACTION, name = android.content.Intent.ACTION_MAIN),
        @Intent(type = IntentType.CATEGORY, name = android.content.Intent.CATEGORY_LAUNCHER)
public class HelloAndroid {

    @Inject @View(
    private TextView textView;

    @Inject @Resource(R.string.hello)
    private String helloText;

    public void hello() {

Although syntactically different than the standard Android Activity, this should seem familiar to the seasoned Android developer. With Transfuse, the properties previously defined in the AndroidManifest.xml file are now defined and associated directly with the Activity code. This follows the Don’t Repeat Yourself (DRY) principle, keeping the Activity definition in one place instead of split between class files and xml resources. There is no longer a requirement to extend Activity (or one of its extension classes) and define the typical boilerplate plumbing code. Transfuse allows development of Android components in a POJO way, unrestricted by the extension-based API of Android.

Build and Deploy

Transfuse requires a full build to generate the necessary class files and resources. Use Maven or Ant to cleanly build projects each time to deploy applications.

mvn clean package android:deploy

A fully functional Android application has now been built using Transfuse.

Fork me on GitHub