Thursday, May 24, 2012

Is there any way to run Python on Android?


I like the Android platform. Actually, with some friends, we even participate to the ADC with the Spoxt project.



But Java is not my favourite language at all. We are working on a S60 version and this platform has a nice Python API. Of course there is nothing official about Python on Android, but since Jython exists, does anybody know a way to let the snake and the robot work together ?


Source: Tips4all

13 comments:

  1. There is also the new ASE project, it looks awesome, and has some integration with native Android components. Android Scripting Environment

    ReplyDelete
  2. "The Pygame Subset for Android is a port of a subset of Pygame functionality to the Android platform. The goal of the project is to allow the creation of Android-specific games, and to ease the porting of games from PC-like platforms to Android."

    The examples include a complete game packaged in an APK, which is pretty interesting.

    ReplyDelete
  3. I just posted some directions for cross compiling Python 2.4.5 for Android. It takes some patching, and not all modules are supported, but the basics are there.

    ReplyDelete
  4. There's also SL4A written by a Google employee.

    ReplyDelete
  5. As a python lover and Android programmer, I am sad to say this is not really a good way to go. There's two problems.

    One problem is that there is a lot more than just a programming language to the Android development tools. A lot of the Android graphics involve XML files to configure the display, similar to HTML. The built-in java objects are really integrated with this XML layout, and it's a lot easier than writing your own code to go from logic to bitmap.

    The other problem is that the G1 (and probably other android devices for the near future) are really not that fast. 200 Mhz processors, and RAM is very limited. Even in Java you have to do a decent amount of rewriting-to-avoid-more-object-creation if you want to make your app perfectly smooth. Python is going to be too slow for a while still on mobile devices.

    ReplyDelete
  6. I've posted instructions and a patch for cross compiling Python 2.7.2 for Android, you can get it at my blog here: http://mdqinc.com/blog/2011/09/cross-compiling-python-for-android/

    EDIT: I've open sourced Ignifuga, my 2D Game Engine, it's Python/SDL based and it cross compiles for Android. Even if you don't use it for games, you might get useful ideas from the code and the builder utility (named Schafer, after Tim...you know who).

    ReplyDelete
  7. Check out this blog here that explains how to install and run python and a simple webserver written in python on Android.

    http://www.saffirecorp.com/?p=113

    ReplyDelete
  8. Not at the moment and you would be lucky to get Jython to work soon. If you're planning to start your development now you would be better of with just sticking to Java for now on.

    ReplyDelete
  9. Given the Oracle lawsuit, lets just lobby Google to replace Dalvik with Pylvik and be rid of Larry and the J2me, which I've seen called an overly verbose mess by people who gave impressive code examples...

    I guess there's ASEand this 10-step instruction and this cool example
    and the SL4A Wiki

    ReplyDelete
  10. PySide (Python QT Bindings) on android:

    http://thp.io/2011/pyside-android/

    ReplyDelete
  11. There's also python-on-a-chip possibly running mosync:

    http://groups.google.com/group/python-on-a-chip/browse_thread/thread/df1c837bae2200f2/02992219b9c0003e?lnk=gst&q=mosync#02992219b9c0003e

    ReplyDelete
  12. Using SL4A (which has already been mentioned by itself in other answers) you can run a full-blown web2py instance (other python web frameworks are likely candidates as well). SL4A doesn't allow you to do native UI components (buttons, scroll bars, and the like), but it does support WebViews. A WebView is basically nothing more than a striped down web browser pointed at a fixed address. I believe the native Gmail app uses a WebView instead of going the regular widget route.

    This route would have some interesting features:


    In the case of most python web frameworks, you could actually develop and test without using an android device or android emulator.
    Whatever Python code you end up writing for the phone could also be put on a public webserver with very little (if any) modification.
    You could take advantage of all of the crazy web stuff out there: query, HTML5, CSS3, etc.

    ReplyDelete
  13. From the Python for android site:


    Python for android is a project to create your own Python distribution including the modules you want, and create an apk including python, libs, and your application.

    ReplyDelete