Python on Android

I have been experimenting with writing Android apps using Python.  Currently, there appear to be two contending ways to do this: Kivy, which looks promising and focuses on providing a clean, cross-platform way to manage multi-touch interfaces; and PGS4A, or Pygame Subset for Android, which is pretty much what it sounds like: a toolchain for packaging an application, written in Python using Pygame, into a single .apk file.

I will focus on PGS4A here.  I like what I have seen so far, and not just for my own recreation.  When tackling graphics in Python, students often gravitate toward Pygame on their own.  I like the idea of providing a relatively straightforward means of deploying students’ projects from desktop to smart phone, even if only as a “teaser” demonstration of this kind of portability.

The documentation on PGS4A is reasonably good, but I did encounter a few hiccups that are worth recording.  In particular, I wanted to see if I could get an app working that involved GUI widgets, which are not provided by Pygame out of the box.  Following is a hopefully more complete list of start-to-finish instructions, including how to use additional modules like PGU (Python Game Utilities), a Pygame-based GUI widget library.

Installing Python

  1. Install Python 2.7, adding C:/Python27 to your PATH environment variable.  (Where the operating system matters, I’ll focus on Windows here, because if you’re using Linux, then you already know what you’re doing, don’t you?)  Note that the link is to the site for Visual Python, which isn’t needed here, but is a handy one-stop shop that includes several useful modules, like Numpy, under the hood.
  2. Install Pygame 1.9.1.
  3. Install PGU 0.18 by unpacking the zip archive to a temporary folder, and running install.
  4. At this point, you should be able to develop and run Pygame applications on your desktop.

Installing Pygame Subset for Android

  1. Install the Java Development Kit (JDK), setting the environment variable JAVA_HOME to point to the JDK installation folder, and adding %JAVA_HOME%/bin to your PATH.
  2. Install PGS4A 0.9.4 by unpacking the zip archive to a permanent folder (e.g., C:/pgs4a), and running installsdk.  For development purposes, I recommend creating a signing key during the installation process, to make the build/deploy/test cycle simpler (you don’t have to keep entering your keystore password).  You can always re-sign with a more secure key later.

Creating an app

At this point, you are ready to create an app.  In the pgs4a folder, create an app folder containing all required files.  At a minimum, this includes, which must have a main() function.  The example on the PGS4A site works on Android, but is missing some housekeeping required to also work cleanly on your desktop.  Following is a modified example:

"""Example app using PGS4A (Pygame Subset for Android).

This example is taken from:

with the following modifications:

    1. Check for ev.type == pygame.QUIT.
    2. Call pygame.quit() explicitly.  This is required on Windows when
        running from IDLE.

import pygame

# Import the android module. If we can't import it, set it to None - this
# lets us test it, and check to see if we want android-specific behavior.
    import android
except ImportError:
    android = None

# Event constant.

# The FPS the game runs at.
FPS = 30

# Color constants.
RED = (255, 0, 0, 255)
GREEN = (0, 255, 0, 255)

def main():

    # Set the screen size.
    screen = pygame.display.set_mode((480, 800))

    # Map the back button to the escape key.
    if android:
        android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE)

    # Use a timer to control FPS.
    pygame.time.set_timer(TIMEREVENT, 1000 / FPS)

    # The color of the screen.
    color = RED

    while True:

        ev = pygame.event.wait()

        # Android-specific:
        if android:
            if android.check_pause():

        # Draw the screen based on the timer.
        if ev.type == TIMEREVENT:

        # When the touchscreen is pressed, change the color to green.
        elif ev.type == pygame.MOUSEBUTTONDOWN:
            color = GREEN

        # When it's released, change the color to RED.
        elif ev.type == pygame.MOUSEBUTTONUP:
            color = RED

        # When the user hits back, ESCAPE is sent. Handle it and end
        # the game.
        elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_ESCAPE:
        elif ev.type == pygame.QUIT:

# This isn't run on Android.
if __name__ == "__main__":

In addition, you must include in the app folder any other dependent files or modules used by your program (e.g., fonts, sprite images, the PGU module, etc.).  For example, pygame.font.Font(None, font_size) does not work, since the Pygame default font is not explicitly included in PGS4A.

Which brings us to PGU.  You will need 3 things in your app folder to use PGU GUI widgets:

  1.  This module is required by PGU, and is bundled with Python (in C:/Python27/Lib), but it’s not included in PGS4A, so you must put a copy in your app folder.
  2. The PGU module itself, copied from C:/Python27/Lib/site-packages/pgu to pgs4a/app/pgu.
  3. The GUI “look and feel” themes are in C:/Python27/share/pgu; copy these to pgs4a/app/share/pgu.

Finally, those GUI themes use some TARGA .tga image files, which PGS4A currently does not support.  Fortunately, this was easy to fix: just convert those .tga files to .png, and change the corresponding filename extensions in the config.txt files in pgs4a/app/share.

Once all of these code files are in place, from the pgs4a folder, run configure app, followed by build app release (or build app release install if you have an emulator or physical device connected).  The resulting .apk file is in pgs4a/bin.

This entry was posted in Uncategorized. Bookmark the permalink.

68 Responses to Python on Android

  1. Help pls!
    I can run my game’s code on windows and play, I can even configure it, build it.
    I see the built game on my emulator with the icon i used. But when i run the game in my emulator, I see a black screen. I even tried it using the modified code u posted (initially i thought the android part of my code has a bug).

    pls help me! I’m stuck here, If I cant run it on an android device, I cannot move forward!
    I dont have an android phone,

    • Is your code posted somewhere (github, stackoverflow, etc.), where someone can take a look, and possibly reproduce the problem if it’s specific to the emulator?

      • Ya thats a good idea. But i was following a video tutorial and reproduced the same code he was using and it ran for him. But it doesn’t run in mine.
        I switched to java (eclipse) now 😦 But looking forward for a solution to get back to python before I can get an Android phone in hand.

        Btw ur demonstration is excellent. Thanks 🙂

  2. For me, this test app runs fine on windows as well. when I compile it as apk and install it on my android device it starts up showing the pygame start screen and afterwards just closes without warning. i even removed all the escape paths from the endless loop, but it still closes, so I assume it crashes in some fashion, rather than detecting an “escape button” action…what am I doing wrong

    • I’m not sure. The first thing I would recommend is to use the adb logcat tool to inspect the output for any error messages. This should give you some information about where it’s crashing.

    • you need to name the script “main” if you want it to run. It’d help if this was somewhere in the documentation

      • In their defense, I suppose it *is* in the documentation (see here), and mentioned here in the post (“…containing all required files. At a minimum, this includes, which must have a main() function”)… but you’re right, it’s not really made explicit that it *won’t* work if you *don’t* use this module and function name.

  3. Craig Oda says:

    Did you ever go back and take a look at Kivy again? I’ve been using Pygame to teach my son to program for a year. It’s great, but I wonder if Kivy has more momentum?

    I don’t have any experience with Kivy.

    You can see what we’re doing here:

    It’ll give you an idea what I’m trying to do with my child.

    • This looks pretty cool! I have been watching Kivy, but I haven’t moved to it in the classroom. Since we don’t focus specifically on mobile development (this is more of an extension of the students’ math class), we have continued to use Pygame, since it also provides a handy interface to external devices like an Xbox 360 wireless controller. (It looks like Kivy has an “androidjoystick” as well, but I’m not sure how well it works, or exactly what it does, since documentation currently is nonexistent.)

      Having said all that, if your focus is mobile development, then I certainly agree that Kivy seems to be getting its legs. If I were going to write an Android app in Python, I’d probably use Kivy. But as a teaching tool, I’m not sure it fits what I’m doing… yet :).

      • Craig Oda says:

        Thanks for the response. My son is in 9th grade right now. He’s taking geometry. My main purpose is to teach him programming. The mobile aspect is to keep his interest up. I started off with just pygame on the desktop and spent a lot of time working with him to develop games with the Xbox controller. This was going fine, but it was difficult to keep the motivation up. I moved the curriculum to the Android phone and his interest picked up when he realized he could show the games to his friends at school.

        I think that if I were in a classroom, I would just keep to pygame on the desktop because one student could show the game to the other student. However, since I am teaching him at home, he needed a way to transport his game and show it to friends.

        I’m going to look into Kivy. I’d be interested in learning more about what your students are doing with Pygame. Is there a link for the projects that your students are working on? Feel free to send me a direct message via email. It may give my son more motivation to see what other kids are doing.

  4. I don’t have the students’ projects from past years (we just started a new school year last week) hosted anywhere online. But I can give some examples from last year that were pretty cool:

    One student wrote a Battleship game, with the computer as one of the players, with some basic AI to select moves. Another wrote a “snake” game (similar to this), where the animation approach is interesting, involving a ring buffer of snake “segments” rather than moving individual sprites around.

    But I find that most of the larger final projects tend to use Pygame just for interface stuff, either reading the joystick, or playing sounds. For graphics, the students tend to prefer Visual Python (see here, for example) with its 3D capability and simpler event handling. Here the list is longer: Conway’s Game of Life, maze solving, first person shooters, projectile motion stuff, etc.

  5. sunhj says:

    if myapp has more than one image resource,can i put them to one folder and put the folder with the at the app

    • Yes. If C:\pgs4a is the installation folder, so that your app is in C:\pgs4a\app\, then for example you can put image files in C:\pgs4a\app\images\*.png, and load them using relative pathnames like ‘images/foo.png’.

  6. Julien says:

    HI thanks for your job!
    I’ve tried your code and your tutorial… and nothing goes right. I always have a black screen when launching the app in the emulator which closes immediately. Whereas the “ build myapp release install” tells me that everything is ok (it looks like the build succeeded).
    I’ve also tried to launch the app on my android phone and it’s quite the same… I have pygame splash screen and immediate back to the ‘desktop’
    I’ve tried a lot of things and it’s always the same… (I have python 2.7, pgs4a 0.96, I’ve install androidsdk, java development kit…) is there something missing in your example ? Logcat does not tell me anything.
    Furthermore, how can I choose the Api Target before building the app ? it seems to build it for api 8 all the time, even after modifying AndroidManifest.xml to an upper api.
    This way to develop python app for android is just very good for me but I hope I can make it work one day…. 🙂

    • Hmmm. I’m not sure what you mean when you say, “Logcat does not tell me anything.” Running adb logcat should tell you *all sorts* of useful information, including how far the app gets into the loading process, and hopefully what errors/exceptions were encountered that are causing it to stop.

      In particular, I would recommend *intentionally* inserting a raised exception in your Python code (i.e., so that you *expect* it to crash), and verify that you are actually running adb logcat correctly; i.e., you should be able to see your intentionally-raised exception. Get that working first, then remove the intentional raise and see what logcat produces.

  7. Craig Oda says:

    Can you post some sample code of an Android application running PGU?

    Can you test the Android soft keyboard with PGU / pgs4a? I am having problems getting output from the Android software keyboard to appear on the screen. I am using a different GUI called SGC. However, if PGU has more features, especially working text input with the Android keyboard, I will switch and investigate it more.

    • Just want to let you know I’m not ignoring you :), but work is dominating my “free” time right now. Briefly, though, this may not be straightforward with PGU, either. Note that the PGS4A API provides functions, android.show_keyboard() and android.hide_keyboard(), that you must call explicitly to pull up the keyboard. Whether this works cleanly with PGU text fields is something I haven’t experimented with. (My main goal was just a menu/clickable control interface.)

      • Craig Oda says:

        Thanks. I wrote a sample program to capture text from the android.show_keyboard() method. The blog post below has a link to the GitHub repository with the example code.

        I went through a SGC tutorial with my son last night and we ran into a few snags with the curriculum, not with the library itself. I still haven’t got the SGC text box to work properly. Oh, the GitHub repository example also has an example of SGC in it.

        I’m still interested in trying out PGU at some point when you have a bored moment. 😉 The example using the game loop (not the PGU loop) that ships with PGU was a bit difficult for me to follow.

  8. Manolo says:

    i got an error that says;
    buildfile: build.xml does not exist
    build failed

    help please, i already updated de sdk but it doesn.t work, what can i do

    • Have you tried the PGS4A forum (here)? They should be able to help with setup issues like this. (A quick Google search of this error message yields quite a few hits as well.)

    • Craig Oda says:

      Read my FAQ, it may help.

      I suspect that problem is that you do not have the Google APIs installed properly.

      Did you manually call up android (not and see a GUI window pop up then manually install API 8 and API 15 from the Google site? If you did not do this, then ant is most likely failing because it can’t build against the API. Just and FYI, API 8 is Android 2.2

      I’ve seen this problem often. It is usually because you don’t have the Android API (not just eh SDK) install. the installsdk usually correctly installs the SDK, but NOT the APIs.

      If the build.xml fails on the licensing portion, you’ll need to do something else. I’ve documented that on my site as well. Good luck.

  9. Pingback: Best Python GUI for Pygame, pgs4a, Android Phones | Android uygulama indir ,bedava app indirme ve mobil oyun sitesi

  10. I get the star_pusher game at: and compile it with pgs4a, but, to make it good for a handeld system I needed to modify its code to improve sertain functionalityes, like a menu to choose level and players and so on, its because in a phone I only operate with a mouse, so I use the zMenu class to implement these issues, but in a class, the mouse don’t work, wy?

    thank’s a lot!

    • I’m afraid there is not enough “trouble report” information here to provide a helpful response. When you say “the mouse don’t work,” *how* does it not work? Is it unresponsive, or does your code generate errors, if so what are the error messages, etc.? Also, I’m not familiar with “zMenu,” is this an object in some class library?

      • Hi, very thank’s to response, ok, I will try to be more clearly:
        My code is ok, but the mouse only work when I load the class in my desktop.
        I choose to use zModule:, but when I compile it with the pgs4a end install it in the phone, it stop to work, but this only happens when I call an item that is in a class, and only for the class, e.g, it dont occur in the normal controls of the code

        if you cam help-me, I can send the code for you


  11. @Armando: I haven’t used zModule, but downloading and browsing the code, I see at least one potential issue; note from the original post: “In addition, you must include in the app folder any other dependent files or modules used by your program (e.g., fonts, sprite images, the PGU module, etc.). For example, pygame.font.Font(None, font_size) does not work, since the Pygame default font is not explicitly included in PGS4A [my emphasis].”

    I see instances of font=None throughout the implementation of So a first thing to try is to include the default font freesansbold.ttf in your app. (Note also that “adb logcat” is your friend– if this is indeed the problem, or at least one of the problems, you will see the appropriate error messages in the debug log.)

  12. Pingback: Jeux Android avec Python, Pygame et PGS4A : l’installation | 16 Couleurs

  13. Marco says:

    Very nice post. I went through the hard path myself, the only differences I see in what I did are:
    – I copied the gui and data folder directly from under pgu-0.18; this should work even if you don’t install PGU but just unzip it. The folder can stay “data”, no need to rename it to share
    – I haven’t had the need to copy, but I just have an app with some buttons so maybe it’s needed for something more complicated

  14. Tom Arnall says:


    I am having problems with font rendering. The code below runs on my PC under Linux, i.e., it prints “hello world” on the window it produces. But when I make it into an apk with the pgsa-0.9.4 kit and run it on my phone, it puts garbage on the screen.


    I’ve put pygame apps on the phone which don’t use the Font objects and
    they run fine.



    import pygame, sys, os, random
    from pygame.locals import *
    import time
    import android
    except ImportError:
    android = None

    def stop(interval=3):
    print “stopping >> ” + str(interval)


    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)

    width = 400
    height = 400

    screen = pygame.display.set_mode((width, height))

    background = pygame.Surface(screen.get_size())
    background = background.convert()

    surface = pygame.Surface((width,height))

    font = pygame.font.Font(“data/Vera.ttf”, 25)

    itemSurface = font.render(“hello world!”, True, BLACK, WHITE)
    surface.blit(itemSurface, (0,0))
    background.blit(surface, (0,0))



    • Hi, Tom Arnall!
      here’s looking that said source is missing, maybe if you copied this file to a folder and force the application to install this source together.
      try this, I hope it helps.

      • Tom Arnall says:

        Armando. thanks for yr reply, but i don’t understand it. for example i don’t understand what file you are talking about (“if you copied this file”). also “source is missing.” what “source”? but i think you may be on to something which is relevant to my problem. please pursue this thread with me.

    • Although this may not be the *only* problem, one issue that I see is that you’re missing a main() function, which is the entry point for a pgs4a app as described in the documentation here.

      • Tom Arnall says:

        thanks for yr reply. no difference if i wrap the code with ‘def main’ etc. also i’ve used pgs4a to port 2 apps which work fine and don’t use the ‘def main’ wrapper. but those 2 apps don’t use fonts.

  15. @Tom, this is interesting, particularly since both I and others in the comments have found that pgs4a (1) imports the ‘main’ module, and (2) calls main.main(), which means that (1) your top-level program file must be named and (2) it must contain a function called main(). I am guessing that your previously successful programs are actually at least *exiting* abnormally, since they “run” during the *import* (and not the subsequent function call). I would be curious to see a pastebin or a gist of an app without such a main() function that you find works, to see if I can reproduce its behavior.

    One other thing I have found with fonts is that the very common font=None argument does *not* work, and you must specify the font name explicitly (as you are already doing in your posted example). However, what I have *not* tried is specifying a qualified *path* name as a font argument, instead of just a filename. You might try that as well (i.e., move the .ttf file up to the same level as your and see what happens.

    Finally, have you looked to see what if any errors are being reported using adb logcat? This is the single best way to troubleshoot problems like this.

  16. Tom Arnall says:

    Do you have an app that does font
    rendering correctly when ported to
    android with pgs4a? If so, this might
    be a good starting point for us to
    discuss the font rendering problem
    I am having.

    The rest of my post is inline to yours.

    >@Tom, this is interesting, particularly
    >since both I and others in the comments
    >have found that pgs4a (1) imports the
    >‘main’ module, and (2) calls
    >main.main(), which means that (1) your
    >top- level program file must be named
    > and (2) it must contain a
    >function called main(). I am guessing
    >that your previously successful programs
    >are actually at least *exiting*
    >abnormally, since they “run” during
    >the *import* (and not the subsequent
    >function call). I would be curious to
    >see a pastebin or a gist of an app
    >without such a main() function that you
    >find works, to see if I can reproduce
    >its behavior.

    Indeed, they do exit abnormally when
    running on the android. i’ll post the
    code here anyway if you want. For now
    this doesn’t matter to me. Other than
    this they run fine on android.

    >One other thing I have found with fonts
    >is that the very common font=None
    >argument does *not* work, and you
    >must specify the font name explicitly
    >(as you are already doing in your posted
    >example). However, what I have *not*
    >tried is specifying a qualified *path*
    >name as a font argument, instead
    >of just a filename. You might try that
    >as well (i.e., move the .ttf file up to
    >the same level as your and see
    >what happens.

    I have tried it both ways. Neither

    >Finally, have you looked to see what if
    >any errors are being reported using adb
    >logcat? This is the single best way to
    >troubleshoot problems like this.

    Yes. I have searched in logcat output for
    anything hinting of a font-related
    activity. Other than the following
    I haven’t found anything.

    I/python (10479): extracting lib/pygame/
    I/python (10479): extracting lib/pygame/sysfont.pyo

    If on the other hand I put a fictitious
    name in the object creation statement i

    I/python ( 7756): File “apps/font.error.example//”, line 41, in

    I did this just to make sure i knew how
    to examine the logcat output for font-related

    Perhaps related to this area, i have
    decompiled the apk and examined the
    result. There is no ‘ttf’ asset. Shdn’t
    one be in the apk bundle?

    Thanks very much for the help you have
    been giving me.

    BTW, I notice that you specify
    installing PUG in yr instructions on the
    use of pgs4a. But I don’t see the use of
    it in the example script. Is it
    necessary anyway to get pgs4a to work?

    • @Tom, re PGU, no, it isn’t required. I just mentioned this in the post since I was experimenting with it as a widget library (which I have not ended up actually using in any applications).

      Here is an example of a bare-bones app that involves font rendering. Note that it is nearly identical to the one in the post, with the addition of the font load, render, and blit. Looking at this more closely, and comparing with your code, I also do not see an android.init() call anywhere. I’m not sure what all goes on during that call, but it may be necessary to not only call android.init(), but also to *wait* to load any fonts until *after* that call.

      • Tom Arnall says:

        YOU’RE THE MAN!
        thanks very much. I’ll get back to you soon with details on what was causing the problem in my own script. And thanks too for your howto for pgs4a. It’s the easiest one to follow that i know of.

      • Tom Arnall says:

        I tried to determine exactly why yr code works. I did it by removing everything I could without making it fail. Below is what I came up with. Notice that even the refs to android have been removed.

        Notice that flip() is repeated three times. Repeat it only 2x and the script fails to display the text.

        Possible explanations earnestly solicited.

        Thanks again for the help you’ve been giving me.


        import pygame
        import time

        def stop(interval=3):
        print “stopping >> ” + str(interval)

        screen = pygame.display.set_mode((480, 800))

        font = pygame.font.Font(‘freesansbold.ttf’, 44)
        text = font.render(‘Test’, 1, (255, 255, 255))

        screen.fill((0, 0, 0))
        screen.blit(text, (50, 50))



  17. Craig Oda says:

    That’s a good point, Tom Arnall could try to put
    import android



    directly into the code, not in an if statement. then, just try and run it only on Android. Also, test it first with no sound. The mixer is handled differently. Make sure that the font file is in the same directory as

    Good luck. pgs4a is a lot of fun.

  18. @Tom, I’m not sure why you would remove the Android-specific calls. At any rate, why it happens to work without them depends on the underlying implementation of pgs4a, which I’m not familiar with. (That is, I think you are simply getting lucky that it works at all *without* the initialization, etc.)

  19. Tom Arnall says:

    Thanks for responding to my post.

    I have removed everything that wasn’t necessary to get the text rendering to work. The idea is to reduce the variables in order to get a better understanding of how text rendering in general is handled under pg4sa. I doubt if my app of interest would work without the android refs. Concerning the text rendering itself, I would like to find a way to make it happen without the repeated calls to display.flip() . Or is it possible that this behavior applies to flip() in general? I find it interesting that 3 calls to it is consistently the minimum necessary to make the text visible on the android device.

    Have you worked with pygame_sdl2? If so, I’d appreciate hearing of yr experience with it.

  20. Tom Arnall says:

    i am trying to get the splash screen feature in pgs4a to work. i notice in template/ there is:


    But neither has any result. Instead the first screen I get on the hand-held is random garbage. Is there a way to get a real splash screen with pgs4a? I know you can put an image on the screen within and then use time.wait() to keep it there for a few seconds, but that route won’t work for the effect I want.

    • Is your program embedded in a def main() function, which in turn is calling android.init() as in the documentation? The splash screen works fine in that case.

    • Craig Oda says:

      This video might help. The splash screen works fine. My son has made many games and apps with a splash screen. Make sure you have the file in the same directory as You’re doing the build with just the name of the directory that contains , right? What phone are you using? I’ve tested it with Moto-G, Samsung Galaxy Note, and LG Optimus. Is your phone resolution 480 x 800? If not, try setting the mode to the same resolution as your phone. It should resive, but sometimes it doesn’t, depending on the specific phone. make the splashscreen the exact size as your phone screen resolution and call it android-presplash.jpg

      The script normally takes care of everything fine, but it seems you have some problem. I’m probably going to start teaching my daughter again in a few weeks and will take another look at pgs4a. Too bad the pg24a forum got spammed and Tom shut down the pgs4a forum. it’s a pretty nice tool to get games running on Android, much easier than a hybrid HTML5 app method.

      • Tom Arnall says:

        Thanks Craig. BTW, I looked at your webpage a few days ago. You guys are amazing! Immense thanks to you for your great work with your kids. And think of all the other kids you’re helping through helping your own.

        Have you looked at Tom’s work with SDL2? I’m very interested in it. I’m hoping the pygame community will settle down and unite behind Tom’s effort. From what I can see, it’s the best route for Pygame”s next move forward in the world of Android. I work with kids too (tutoring in Mexico) and for them Python/Pygame is a much better first step into writing Android apps than Java.


      • Craig Oda says:

        Tom, I have not used SDL2. What is the advantage? i’ve found several issues with pgs4a / pygame that might be problem for a production game, but no show-stoppers for children. I encourage you to teach the kids in Mexico about building games with Pygame for Android phones. It seems like a good match with low-cost Android phones readily available in Mexico. I’ve also built video games on the Raspberry Pi using Pygame, though the mobile phone seems to be the big draw. On TV screens with the Raspberry Pi, I’ve had some issues with the performance of XBox-style joysticks. It’s usable, just slows down sometimes. Finally, one of the early challenges I had with teaching was in finding good sources of high-quality graphic and music assets. HumbleBundle recently had a game developer bundle and I bought a bunch of assets really cheaply. I also found assets on the old Glitch Game site that are in the public domain now. The flat-image sprite sheets are the ones to get:

        Good luck with the kids in Mexico. Seems like a cool project.

    • Jaakko says:

      I’m having the same problem. I have a game published on google play, “Airspace Control” and came across this same issue through users sending feedback. Long story short, I narrowed the problem to Jelly Bean API levels 16 – 18. On other devices, the presplash screen works fine (API levels 9-13), and is usually blank on newer API levels (19-22). Once I find the reason / fix for this, I will post my findings here.

      • kloro2006 says:

        how are you making it happen on the other devices? i’m running 4.2.2 on both of mine and nothing is happening but random junk on the screen. i’m wondering if the problem is that i only have a 2.2 device installed in my android-sdk.

      • Jaakko says:

        Unfortunately I still haven’t found a solid solution or cause for this issue. I have some leads which I’m pursuing and as soon as a get the answer, I will definitely post it here. This seems to be a quite common problem with other build tools as well. FYI: per the question below, I’ve tried using .jpg, png and .9.png files to no avail. Also, I’ve tried targeting different SDK versions, and it still doesn’t work properly. I’m using the older version of pgsa4 (0.9.4) for packaging the game. I can confirm that the splash screen shows up correctly on Android 4.4 (Samsung Tab 3) and is black on all other higher API devices that I’ve tried, also the splash screen remains black on devices running 4.4 (Kit Kat) with a high DPI ratio. I’ll try to look into this again today.

      • Jaakko says:

        Just a quick note on my findings today (maybe it’ll help someone else). The problem (for pgs4a version 0.94) is in “./src/org/renpy/android/”. Essentially it boils down to an OpenGL problem. I messed around with the java code and managed to get the splash screen working on all devices, however doing this crashes the game – now I’m looking into that issue. Anyway, looks like this has been fixed for pgs4a 0.9.6, but since the pgs4a site is now off-line and I don’t have the “pgs4a-0.9.6.tar.bz2” and getting 0.9.6 working on Windows (for which I do have it) is a pain, I’m going to have to find a 100% working fix for version 0.9.4.

    • Jaakko says:

      I finally found a fix for the scrambled / missing pre-splash screen issue (Windows 7, pgs4a-0.9.4 build). Instructions below (I hope this helps someone else struggling with this same issue):

      In: \pgs4a-0.9.4\src\org\renpy\android\ replace “” with “” (from 0.9.6)
      You will need to modify line 254 in: \pgs4a-0.9.4\src\org\renpy\android\ to this:
      if (mView != null && mView.mStarted && SDLSurfaceView.nativeKey(keyCode, 1, event.getUnicodeChar())) {
      Also modify line 263 in: \pgs4a-0.9.4\src\org\renpy\android\ to this:
      if (mView != null && mView.mStarted && SDLSurfaceView.nativeKey(keyCode, 0, event.getUnicodeChar())) {

      Then in \pgs4a-0.9.4\libs\armeabi\ copy (from 0.9.6) and replace all SDL files;

      If you encounter any problems, send email to:
      Please also check-out my first game:

      • Tom Arnall says:

        thanks for your persistence Jaako!

        has anyone used pygame_sdl2 and RAPT to create android apps? if so are they having the splash-creen problem with that setup?

  21. kloro2006 says:

    what file names are you using for the splash file?

  22. kloro2006 says:

    @Craig Oda
    About my interest in SDL2, the folks at SDL are clearly committed to the new version, so it will be getting most if not all of their support work. More important to me, SDL2 is a big step forward in many ways. The ones that interest me most right now are faster performance and support for more handheld capabilities, e.g., multi-touch. The SDL website provides an interesting article on the subject: There are other advantages i’m sure, ones which I can’t yet appreciate because i am very new to game programming and android apps. Also, most of the pygame developers are, best I can tell, moving pygame to SDL2.

    • Craig Oda says:

      I’ve only recently realized that pgs4a development moved to pygame_sdl2 and RAPT. My son got involved with Javascript, angular, bootstrap and some other backend technologies. This put our Android dev on hold. My daughter has been working with Pygame on the desktop and on Raspberry Pi. I’ve been using Kivy more, but I don’t think it’s appropriate for elementary school curriculum. Right now, I’m working with children using Pygame + Raspberry Pi. Does PySDL2 support multi-touch on Android? I’m not sure I want to dive into that or just keep using Kivy.

  23. Matthieu says:

    Hi, I tried a lot to install a little app on my phone that I made but I’ve got an annoying issue : “keystore was tampered with, or password was incorrect : Password verification failed”.
    I seem to be the only one having problems with the keystore so if someone can explain me why it’d be great ^^
    The fact is that I had a first issue that I solved by myself, I didn’t had any keystore named “android.keystore” in my main folder… So I created one, by searching on internet but I’m never asked to put my password so I don’t really know what to do …
    Sorry for my bad english, I’m french, thanks you for the answer, see you !

  24. Jan de Lange says:

    Good post! I cannot get the .png assets to be included. The Android emulator Genymotion complains that the .png files are not found. You mention a config.txt file to set paths to files, but I cannot find this file. There is no pgs4a/app/share directory on my install. Other than this the whole compilation process seems to work, I get “The build seems to have succeeded”. So where do I need to put the grapics files?

    • In the pgs4a clean install, there won’t be an “app” subfolder; this is a folder that *you* create (see the “Creating an app” section in the post) to contain all of the code and resources (images, etc.) for your app. It’s worth noting that this folder doesn’t have to be named “app”; you can name it whatever you want, just use that name in place of “app” in all subsequent commands (e.g., “ configure app”, etc.).

      Also, the ./app/share subfolder and config.txt file are specific to the PGU widget library, so if you’re not using it, you can skip this. Just put your .png files in *some* folder underneath the top-level pgs4a/app (or whatever) folder that you have created. For example, if your app is named “foo”, then create a folder structure that looks like pgs4a/foo/, pgs4a/foo/images/image1.png, etc. Then in your, you should be able to pygame.image.load(‘images/image1.png’).

  25. Jan de Lange says:

    Wow, that’s fast! Indeed, I do not use PGU. My folder structure ../rapt/game/data/ where rapt contains the pgs4a files, /game/ has the and other class .py, .pyc and .pyo files, and /data/ has the .png files. does not call the images, but a sub-class does in the format you mention: self.image = pygame.image.load(‘data\start_button.png’) To compile I call the following from within …/rapt/: python –launch build game release install, this compiles and loads the app in the emulator, but with the error: “Couldn’t load png16: findLibrary returned null”, I am assuming 16 refers to the bit size of the file.

    • This helps– from the ./rapt/ in the folder structure, I think the next things for you to investigate are version numbers. What version of Python and pgs4a are you using? I have only tested this with Python 2.7 and pgs4a 0.9.6 (and originally 0.9.4); I note that my links now redirect to RAPT, which I have not experimented with, but looks like a wrapper around the *new* SDL2 wrapper around Pygame? If so, I think you’re a test pilot :).

  26. Jan de Lange says:

    Downloaded the latest pgs4a today here:, (as is advised on the github site). At the dos/command window I notice: Android SDK Tools Revision 23.0.0. Python is 2.7, 64 bit (Miniconda install). Pygame is 64 bit windows version 1.9.2 (pygame-1.9.2a0-cp27-none-win_amd64.whl) dowlnoaded from here:
    I am not qualified to be a test pilot unfortunately. I am an absolute beginner at Python, Pygame and pgs4a. Does pgs4a create a log file? I could forward that or pipe the screen output to a .txt file?

    • I guess what I mean by a test pilot is that we’re *both* beginners when it comes to this re-work of pgs4a (and this is a significant re-work, based on SDL2 instead of the older SDL1). Recommend contacting the developer (username renyptom) as he can probably provide better troubleshooting support than I can.

      • Jan de Lange says:

        I contacted Tom and he’s assisting me in finding the problem. I’ll let you know what we find. Thanks for your help thus far.

  27. Pingback: installsdk error | Mentalist Nuno

  28. Ari says:

    I was using pgs4a to make a game and adding it to my phone, when i made another update in witch i added many images (about 50 .png files) it now gets stuck on “installing …onto default emulator or device… ” and does nothing. Could the problem be that there are too many images?
    p.s. i tried both options when it asked me if i wanted to create and expansion apk.
    Thanks in advanced for the advise.

    • @Ari, good question. I doubt the *number* of files is an issue, but the total *size* of all of those images might be. Unfortunately, it’s been over 4 years since I wrote this post, focusing on versions 0.9.4 and later 0.9.6; pgs4a has changed quite a bit since then, now more cleanly wrapped around SDL2. If you are using the latest, Tom (see links above) may be able to help better than I.

  29. alex Storozhenko says:

    What about python3

  30. Pingback: Android Apps with Python – Raspberry & Arduino

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.