Ren'Py support devices running the Android operating system, such as smartphones and tablets. While these devices do not support 100% of Ren'Py's functionality, with minimal modification code can be packaged and ported to these devices.
RAPT - the Ren'Py Android Packaging Tool - is a program, downloaded separately from Ren'Py, that creates an Android package for testing or release purposes.
When a Ren'Py game has been launched on Android, the following keybindings work:
There are many important differences between the touch-based Android platform and the mouse-based platforms that Ren'Py supports. Changes due to the Android software and hardware are:
In addition, there are a few changes that may be necessary due to human factors:
To help you adapt to these differences, Ren'Py for Android automatically selects a screen variant of touch. It also selects screen variants of phone or tablet based on the device's screen size. See Screen Variants for more information.
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:
Once you've finished these four steps, you'll have a runnable Android package. You'll only need to run step 3 when you decide to make changes to your game's configuration or when configuring a new game entirely; you'll run step 4 most often, whenever you need to make a new build of your game.
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. We will try to assist you with examples to familiarize you with the command line on Windows.
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:
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:
RAPT is not compatible with Python 3 at this time.
Android Device Drivers. On Windows, you may want to install a device driver to access your device, although this is not necessary. Links to android device drivers can be found at:
On Linux or OS X, you won't need a device driver. If you can't access your device, you may need to read:
However, modern versions of Linux and OS X should just work.
RAPT Itself. The latest version of RAPT can be downloaded from:
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.
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, to do this, you will need to open up the command line by pressing and holding down the Windows key and 'R'. In the small window that pops up write "cmd" and press Enter. This should bring up the command line.
To run the command from within the RAPT directory you need to navigate to it from the command line. Find out where you extracted RAPT and copy the path from Explorer (just click in the address bar so the path turns blue and press Ctrl+c). In the command prompt, write cd then a space, a double-quote, paste the path you just copied from Explorer (right click and choose paste), then another double-quote.
Let's assume you extracted RAPT to C:\tools\RAPT. In the command line write:
cd "C:\tools\RAPT"
Now you're within the RAPT directory.
On Windows, if the .py extension is registered to Python 2.7, you then can just run:
android.py test
If you don't know what the above means or you don't want to do it, you will have to add the full path to Python to each command in the following steps of this guide beginning with 'android.py'. If you installed Python to the default location, the above command would become:
C:\python27\python.exe android.py test
If you installed Python to a different location, then find your Python install in Explorer, click in the address bar and copy the path, then replace C:\python27 with the path you copied instead - leaving \python.exe on the
end. So if your Python install is in C:\tools\python, you would type:
C:\tools\python\python.exe android.py test
Warning
If the path to Python that you copied has any spaces in - for example, if you had installed it in the Program Files directory - you will need to put double quotes at the beginning of the whole command and just after python.exe:
"C:\Program Files\Python\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 - if you had to include the path to Python in the example above, you will need to do the same thing every time you see android.py in these instructions.
The next step is to set up the Android SDK and the rest of your development environment. This step will:
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.
In the examples below, mygame is short for the path to the game you're working on, relative to the current directory. When you make your own game, you should change mygame to something else. The easiest way to do this, of course, is to make a copy of your game's directory inside the RAPT directory and then replace mygame in the examples below with the name of your game's directory.
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.
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.
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.
If you'd rather just copy the game's apk file to your Android device manually, you can just run:
android.py build mygame release
Then navigate to the 'bin' directory inside RAPT and copy the file mygame-release.apk into your Android Device. You will then need to find the .apk file in your Android device using your file application and open it to install the
game.
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
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.
Here's a list of errors that you might encounter and possible solutions:
When trying to run:
android.py test
After having associated .py files with Python 2.7, if you get:
Traceback (most recent call last):
File "C:\Visual Novels and Games\rapt-6.13.11.0\android.py", line 9, in <module>
import subprocess
File "C:\Python27\lib\subprocess.py", line 444, in <module>
from _subprocess import CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP
ImportError: cannot import name CREATE_NEW_PROCESS_GROUP
This may be related to having more than one version of Python installed on your system. Try running android.py with the full path to Python, e.g.:
C:\python27\python.exe android.py test
(If this works, then you will need to include the full path to Python in every command, as if you didn't have the file type associated.)
If while downloading Apache Ant you get:
IOError: [Errno socket error] [Errno 10054] An existing connection was forcibly
closed by the remote host
Just try installing the sdk again with the same command.
If while configuring your game you get something like:
Tag <manifest> attribute package has invalid character '-'.
You may have inserted an invalid character in the package name you used during configuration (in this case a hyphen '-'). You'll have to use a different package name which does not contain anything other than letters and dots.
If while configuring you get something like:
Traceback (most recent call last):
File "android.py", line 66, in <module>
main()
File "android.py", line 44, in main
configure.configure(iface, directory)
File "buildlib\configure.py", line 108, in configure
config.save(directory)
File "buildlib\configure.py", line 30, in save
with file(os.path.join(directory, ".android.json"), "w") as f:
IOError: [Errno 2] No such file or directory: 'mygame\\.android.json'
You should check whether you specified the correct path to your game directory. The easiest way to be sure is to put your game's directory inside the RAPT directory, and simply supply the name of your game's directory. (If your game's directory name has spaces, you may need to surround it with double quotes.)
If building your game gives you an error like:
Error: Target id android-8 is not valid. Use 'android list targets' to get the target ids
You might want to check whether you have Android 2.2 (API 8) in the Android SDK manager. You can run it by navigating to the android-sdk/tools directory inside the RAPT directory and run android.bat.
If Android 2.2 (API 8) is missing like in the above image, click 'Updates' and then 'Install Updates'.
Once the updates are installed, make sure Android 2.2 (API 8) and SDK platform are ticked:
And install the packages. Then, try building your game again.
If you still have questions or doubts you can try searching through or posting on the RAPT thread over at the Lemmasoft forums: