### Navigation

- index
- Ren'Py Home |
- Ren'Py Documentation

# Building Android Applications

RAPT contains tools that help you take a packaging-centric approach to Android game development. In this approach, you will use a PC to build an Android package and upload it to your device. You can then run the game like any Android application. When it works correctly, you can upload the package you make to the Android Market or other app stores.

Building your first package takes four steps:

1. Download and install RAPT, Python 2.7, the Java Development Kit, and Android USB Drivers (scroll down for links).
2. Use the `android.py installsdk` command to install the Android SDK and set up your development environment.
3. Use the `android.py configure` command to configure Android-specific settings in your game.
4. Use the `android.py build` command to build a package, and to install the package on your device.

Once you've finished these four steps, you'll have a runnable Android package. You'll then repeat steps 3 (rarely) and 4 (often) until you your game works.

## Host Platform Support

We've tested RAPT on Linux and Windows computers. While it should work on Mac OS X, we haven't tested it there, so there may be problems encountered. The examples we give will be for Linux and Windows.

The RAPT tools are command-line based. This documentation assumes that you are proficient with the basics of command-line operation.

## Step 1: Installing RAPT and its Dependencies

There are four things you may need to manually download and install before you can run RAPT:

Java Development Kit. The Java Development Kit (JDK) contains several tools that are used by RAPT, including the tools used to generate keys and sign packages. It can be downloaded from:

> http://www.oracle.com/technetwork/java/javase/downloads/index.html

Please note that the developer-focused JDK is different from the user-focused JRE, and you'll need the JDK to create Android packages.

Python 2.7. Python 2.7 is required to run the android.py script that's included with RAPT. It can be downloaded from:

> http://python.org/download/releases/2.7.2/

RAPT is not compatible with Python 3 at this time.

Android Device Drivers. On Windows, you will likely need to install a device driver to access your device. Links to android device drivers can be found at:

> http://developer.android.com/sdk/oem-usb.html

On Linux or OS X, you won't need a device driver. If you can't access your device, you may need to read:

> http://developer.android.com/guide/developing/device.html#setting-up

However, modern versions of Linux and OS X should just work.

Itself. The latest version of RAPT can be downloaded from:

> http://www.renpy.org/dl/android/

Once RAPT has been downloaded, you should extract it using an archive program. The directory contained in that archive is what we will refer to as the RAPT directory.

## Aside: Running android.py

In this documentation, we'll ask you to run the `android.py` command. The technique we use to run this varies based on the system you're on.

In all cases, you should run `android.py` from within the RAPT directory. (That is, the directory containing `android.py` itself.)

On Windows, if the .py extension is registered to Python 2.7, you can just run:

    android.py test

Otherwise, you'll have to give the full path to Python 2.7:

    C:\python27\python.exe android.py test

On Linux, you may need to prefix the command with the current directory:

    ./android.py test

For the rest of this documentation, we'll just use `android.py`, and leave it up to you to figure out how to convert that to the appropriate command on your system.

## Step 2: Set up the Android SDK and Development Environment

The next step is to set up the Android SDK and the rest of your development environment. This step will:

- Check that the JDK is installed properly.
- Install Apache Ant.
- Install the Android SDK.
- Use the Android SDK to install the appropriate development packages.
- Create a signing key that will be used to sign packages that are placed on the market.

This step requires Internet access.

To perform this step, run:

    android.py installsdk

RAPT will report on what it's doing. It will also prompt you with warnings about licenses, and ask if you want it to generate a key.

Warning

The key generated by RAPT is created with a standard passphrase. You should really use keytool to generate your own signing keys.

At the very least, you should keep the android.keyring file in a safe place. You should also back it up, because without the key, you won't be able to upload the generated applications.

## Step 3: Configure Your Game

Before building a package, you must give RAPT some information about your game. You can do this with the following command:

    android.py configure mygame

This will ask you a series of questions about your game, and store that information in a file in the game directory.

The only difficult question should be the one about layout. For your first game, you want to put it on the internal storage.

If you need to change the information - for example, if you release a new version of your game - you can re-run the configure command. Your previous choices will be remembered.

## Step 4: Build and Install the Package

Finally, you can build and install the package. This is done with a command like:

    android.py build mygame release install

This command will build a releasable version of your game, and then install it on the connected device. Please look at the output of this command to make sure it succeeds.

Once the game successfully installs, you can touch its icon in your device's launcher to start it running.

The build command passes the options after the game name to the ant tool, which is responsible for creating the Android package. Other commands are also possible - for a list, run:

    android.py build mygame help

## Viewing Debug Output

To view debug output from your application, run the logcat command:

    android.py logcat

This command runs the `adb logcat` command in a mode that selects only Python output.

### Navigation

- index
- Ren'Py Home |
- Ren'Py Documentation