Pygame is a 2D game engine for Python (on desktop) that is popular with new programmers. The Pygame Subset for Android describes itself as…
…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 as an APK, which is pretty interesting.
I’ve also 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 or builder utility (named Schafer, after Tim… you know who).
SL4A does what you want. You can easily install it directly onto your device from their site, and do not need root.
It supports a range of languages. Python is the most mature. By default, it uses Python 2.6, but there is a 3.2 port you can use instead. I have used that port for all kinds of things on a Galaxy S2 and it worked fine.
API
SL4A provides a port of their android library for each supported language. The library provides an interface to the underlying Android API through a single Android object.
from android import Android
droid = Android()
droid.ttsSpeak('hello world') # example using the text to speech facade
Each language has pretty much the same API. You can even use the JavaScript API inside webviews.
let droid = new Android();
droid.ttsSpeak("hello from js");
User Interfaces
For user interfaces, you have three options:
You can easily use the generic, native dialogues and menus through the API. This is good for confirmation dialogues and other basic user inputs.
You can also open a webview from inside a Python script, then use HTML5 for the user interface. When you use webviews from Python, you can pass messages back and forth, between the webview and the Python process that spawned it. The UI will not be native, but it is still a good option to have.
There is some support for native Android user interfaces, but I am not sure how well it works; I just haven’t ever used it.
You can mix options, so you can have a webview for the main interface, and still use native dialogues.
QPython
There is a third party project named QPython. It builds on SL4A, and throws in some other useful stuff.
QPython gives you a nicer UI to manage your installation, and includes a little, touchscreen code editor, a Python shell, and a PIP shell for package management. They also have a Python 3 port. Both versions are available from the Play Store, free of charge. QPython also bundles libraries from a bunch of Python on Android projects, including Kivy, so it is not just SL4A.
Note that QPython still develop their fork of SL4A (though, not much to be honest). The main SL4A project itself is pretty much dead.
As a Python lover and Android programmer, I’m sad to say this is not a good way to go. There are 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 integrated with this XML layout, and it’s a lot easier than writing your code to go from logic to bitmap.
The other problem is that the G1 (and probably other Android devices for the near future) are 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.
I wanted to add to what @JohnMudd has written about Kivy. It has been years since the situation he described, and Kivy has evolved substantially.
The biggest selling point of Kivy, in my opinion, is its cross-platform compatibility. You can code and test everything using any desktop environment (Windows/*nix etc.), then package your app for a range of different platforms, including Android, iOS, MacOS and Windows (though apps often lack the native look and feel).
With Kivy’s own KV language, you can code and build the GUI interface easily (it’s just like Java XML, but rather than TextView etc., KV has its own ui.widgets for a similar translation), which is in my opinion quite easy to adopt.
Currently Buildozer and python-for-android are the most recommended tools to build and package your apps. I have tried them both and can firmly say that they make building Android apps with Python a breeze. Their guides are well documented too.
iOS is another big selling point of Kivy. You can use the same code base with few changes required via kivy-ios Homebrew tools, although Xcode is required for the build, before running on their devices (AFAIK the iOS Simulator in Xcode currently doesn’t work for the x86-architecture build). There are also some dependency issues which must be manually compiled and fiddled around with in Xcode to have a successful build, but they wouldn’t be too difficult to resolve and people in Kivy Google Group are really helpful too.
With all that being said, users with good Python knowledge should have no problem picking up the basics quickly.
If you are using Kivy for more serious projects, you may find existing modules unsatisfactory. There are some workable solutions though. With the (work in progress) pyjnius for Android, and pyobjus, users can now access Java/Objective-C classes to control some of the native APIs.
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 off with just sticking to Java for now on.
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.
I use the QPython app. It’s free and includes a code editor, an interactive interpreter and a package manager, allowing you to create and execute Python programs directly on your device.
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.
Chaquopy is a plugin for Android Studio’s Gradle-based build system. It focuses on close integration with the standard Android development tools.
It provides complete APIs to call Java from Python or Python from Java, allowing the developer to use whichever language is best for each component of their app.
It can automatically download PyPI packages and build them into an app, including selected native packages such as NumPy.
It enables full access to all Android APIs from Python, including the native user interface toolkit (example pure-Python activity).
This is a commercial product, but it’s free for open-source use and will always remain that way.
The Scripting Layer for Android, SL4A, is an open source application that allows programs written in a range of interpreted languages to run on Android. It also provides a high level API that allows these programs to interact with the Android device, making it easy to do stuff like accessing sensor data, sending an SMS, rendering user interfaces and so on.
python-for-android is an open source build tool to let you package Python code into standalone android APKs. These can be passed around, installed, or uploaded to marketplaces such as the Play Store just like any other Android app. This tool was originally developed for the Kivy cross-platform graphical framework, but now supports multiple bootstraps and can be easily extended to package other types of Python apps for Android.
BeeWare allows you to write your app in Python and release it on multiple platforms. No need to rewrite the app in multiple programming languages. It means no issues with build tools, environments, compatibility, etc.
The Scripting Layer for Android, SL4A, is an open source application that allows programs written in a range of interpreted languages to run on Android. It also provides a high level API that allows these programs to interact with the Android device, making it easy to do stuff like accessing sensor data, sending an SMS, rendering user interfaces and so on.
You can also check PySide for Android, which is actually Python bindings for the Qt 4.
There’s a platform called PyMob where apps can be written purely in Python and the compiler tool-flow (PyMob) converts them in native source codes for various platforms.
python-for-android is an open source build tool to let you package Python code into standalone android APKs. These can be passed around, installed, or uploaded to marketplaces such as the Play Store just like any other Android app. This tool was originally developed for the Kivy cross-platform graphical framework, but now supports multiple bootstraps and can be easily extended to package other types of Python apps for Android.
BeeWare allows you to write your app in Python and release it on multiple platforms. No need to rewrite the app in multiple programming languages. It means no issues with build tools, environments, compatibility, etc.
It’s an open source project with both Python 2 and Python 3 implementations. You can download the source and the Android .apk files directly from github.
One more option seems to be pyqtdeploy which citing the docs is:
a tool that, in conjunction with other tools provided with Qt, enables the deployment of PyQt4 and PyQt5 applications written with Python v2.7 or Python v3.3 or later. It supports deployment to desktop platforms (Linux, Windows and OS X) and to mobile platforms (iOS and Android).
According to Deploying PyQt5 application to Android via pyqtdeploy and Qt5 it is actively developed, although it is difficult to find examples of working Android apps or tutorial on how to cross-compile all the required libraries to Android. It is an interesting project to keep in mind though!
Take a look at BeeWare. At the moment of answering this question it is still in early development. It’s aim is to be able to create native apps with Python for all supported operating systems, including Android.