Thursday, May 15, 2014

Windows 8.1 and Pygame Subset for Android (pgs4a)

I recently got asked a question about Windows installation on the PyChildren forum.

Here's the question:

When I touch the icon, the screen turns black, and then it goes back to my apps page in my phone. I then run the logcat to find the problem, but all it gives me is this:


V/python ( 676): Extracting private assets.
I/python ( 676): extracting private.mp3 to /data/data/com.bennybear.fungame/files
The user was not using an mp3 sound file.  When the person extracted the Windows compressed package for pgs4a, the file got added into a sub-directory of the build.    Since I was helping my son to install pgs4a on his Windows 8.1 computer, I was able to replicate the problem.   I think that the process of unzipping or extracting the pgs4a file partially failed.  When I compared the pgs4a files on two different Windows 8.1 computers, I noticed they were different.

I then went to the pgs4a site and downloaded a tar.bz2 archive.  I used tar jxvf on cygwin to extract the files.

A working directory is shown below.




Note that inside of the pgs4a-0.9.6 directory, there is not another sub-directory called pgs4a-0.9.6.  In the failed builds, I noticed that there was a temporary pgs4a-0.9.6 file created in the same directory and all the files from that directory were not properly copied into the main directory.

Once I had the files properly extracted, I noticed that the python android.py installsdk script was giving me error messages.  The script was failing to install android-api-15 and android-api-8.  I used the android.bat program in the android-sdk\tools directory to update the android SDK APIs.  

If you get an error message indicating that ant cannot find the build.xml file, this usually indicates that you don't have the proper Google APIs installed from the Android SDK (not the pgs4a android.py installsdk script).  In almost all cases, I've had to install the Google APIs with the android sdk.  On windows, the android sdk manager is called android.bat

There is another pgs4a tool called android.py.  These tools are completely unrelated.

Once I had those installed, the build went fine.  In order to connect the Windows 8.1 laptop to my son's Motorola Moto G Android phone, I had to go to the Motorola site and install the driver.  With driver from Motorola, adb was able to detect the phone and install went smoothly.

I also installed it on my Samsung Galaxy phone from his Windows 8.1 laptop.


This seems like a pain in the rear, but I encourage you to keep going.  Pygame is fun because it makes it easy to bring the creative ideas from your brain into reality very quickly.   By putting these ideas, your works of art, on a phone, you can show your friends and help them to understand a bit more about how you think as a person.

My long term goal for my children is for technology to serve as a tool for creative expression, not a barrier.  It should be fun and frivolous.  Games are great learning tools.  The work and lessons here should not be viewed through the lens of making money or job-training.  These experiments with children are about developing creative thinking and techniques to express ideas.  Sure, it's a pain to get pgs4a to install sometimes.  I agree.  But, I still think it's the best way to get kids and adults up to speed to be able to take their ideas and prototype them on a mobile phone.  

Have fun!

If you have questions or would like to join the discussion, go to the PyChildren Forum.