So, I've actually been working for the past while on a project to allow building more native apps on Android using Python. It is built on the Kivy tools, but I have had to make some changes to python-for-android specifically because it's not as seperated from Kivy as the developers think. I've also had to make a small change to PyJNIus, as it has a dependency on SDL when on Android.
The reason I chose to work on this is while you can already create an application using Kivy, it sort of exists in its own world compared to standard Android apps. Because you don't have separate activities, you can't really do stuff like have one of them be launched to handle a specific file or URL (disclaimer: what I'm building can't either yet). There's also the same issues you get with mobile apps that are web apps in an APK, where someone has attempted to reimplement native UI widgets and there's certain behaviours that are not quite right or missing, or you can't use them yet because they haven't been replicated in your environment yet.
So basically what I'm doing is the Python equivalent of Xamarin.Android (https://developer.xamarin.com/guides/Android/ ) built on some of the Kivy tools. The idea is that you'd have the bulk of your logic in cross platform Python and a thin UI layer for any platforms you had. And in the future if someone made a similar thing for iOS, you could build a layer overlying the two of them and get actually native behaviour on both.
Overall I've gotten it to the stage where you can create activities, access some standard UI elements and launch third-party apps via Python code, but like I said, it's still at a pretty early stage.
I'd intended to open source it when it got to a more usable state, as it's pretty much in proof of concept state atm. (bugs ahoy, tests and docs are very lacking, feature coverage is low, setup is a PITA, and the API is too close to the Java API to make for nice Python). These are problems I believe are fixable. If you want to see the current state of it though, it's on https://bitbucket.org/tonyfinn/pydroid , but it's a bit off how far I'd like to be before sharing it.
This looks really cool, thanks for sharing it. I've seen this kind of idea talked about many times, but never any implementation, and even if at an early stage there's clearly a lot of effort in your basic structure and api (edit: and docs!).
Yes. There's no JSX analogue for templating, it just uses the android XML layouts so designers can use existing tools, but otherwise it's a pretty similar approach.
Kivy is really cool, but getting started on it sort of sucks. Lots of compilation errors (especially if you're trying to install on windows) due to its dependencies on pygame (and therefore cython, and therefore a particular version of MSVS for the specific dll... all a hassle). The on-site tutorials are sort of obtuse too, if you're looking to do UIs rather than games - until other resources[1][2] became available, I sort of just gave up because it didn't seem worth it to jump through the hoops for a new framework.
Ultimately, short of Android becoming a widely supported platform for Python and having binaries available on PyPI, there's not much that can be done for this. Compiling stuff on Windows is a bit of mess, but a surprsing number of Python libs use or rely on others that use C extensions.
In normal use on Windows, this isn't as noticeable as these projects either have binaries on PyPI for Windows or else installers from their own site, but when you actually do need to compile stuff (because you're cross compiling for Android), it's a bit of a mess.
On Ubuntu it's really easy though.
This is why I switched OSes a few years ago. Things are just easier if you use the same platform as other developers.
Until I entered the workforce proper, I got to work on mostly linux. Since going into the Seattle startup and then consulting worlds, there's a lot of Windows development, even on servers. So I try to be pretty agnostic about dev platform. Kivy doesn't really provide that luxury.
I've never used Kivy, but I'm using Vagrant (https://www.vagrantup.com/) on a daily basis for development and it made all problems with setting up the dev environment the thing of the past for me. I've found something like this for Kivy: https://github.com/Peradine/kivy-android-vagrant it's been 2 years since last commit, but it can be a starting point.
I also did give a try after I saw a post here on HN about a new release. I wasn't very happy with it. There were many bugs that's a complete mess to get started with.
I tried the example on their documentation and got it running on my Linux box (which was very easy), but kept failing on Android due some missing dependency. These issues are not listed on their website, giving the impression it will just work out of the box. There by wasting a lot of time for anyone wanting to give it a try. After much googling I got to find out that SDL is not supported on Android for Kivy. You have to use PyGame and PIL. PIL isn't maintained anymore, so you can't just do:
Pillow didn't work for me, complained that it was compiled for some other platform. With that I was able to get rid of 'No text provider found' dependency error, but still I can't open the application because of some 'Window provider not found' error. I left it at that.
It's a cool project and I'd like to see it succeed, but there is a long way to go. I'd appreciate if someone could post a link on how to setup an environment that setups Kivy to build for Android.
You shouldn't in principle need to worry about the difference between the sdl2 and pygame/sdl backends on Android, since kivy's own API is the same in either case.
You don't need to install pil either (kivy preferentially uses other providers), unless directly using it in your own code, in which case you can include it in the android build by adding it to the python-for-android modules string or buildozer requirements line (just 'pil', this is the name of an internal recipe). If you have a window and text provider problem on android, that indicates that something is wrong with the android build, and we can help to debug if you provide the logs. I'm not sure offhand what problem would allow the android build to complete but give this error, but it would probably be revealed in the log.
Ah, thanks. I suspect this is a bug related to the transition to sdl2, though I'm not sure what makes it present (it doesn't happen to everyone's android build).
If you're interested, one thing to try is (if you're using buildozer) to put 'kivy==master' in the requirements line instead of just 'kivy'. This will download the master branch, which may have a fix for this.
It not that, it's probably an issue somewhere in the python-for-android/buildozer build process, so that log would be the most interesting. If you're able to provide it that would be great, but thanks either way for reporting it.
I teach intro CS to non-majors, and having to explain terminology is cumbersome. For instance, we call things "strings", "floats", and "dictionaries". And then I make them download Anaconda so they can get Spyder to write Python programs. I can't help but wonder what goes through their heads.
Kivy is a fun little library, not without its quirks, but overall I felt comfortable with it.
In particular, it's nice how they built everything around GLSL shaders, this allows for very interesting styling and visual effects.
Also personally I found that the easiest way of getting into Kivy is by dissecting someone else's toy projects. E.g. there is this book with many small programs written in Python with Kivy: https://www.packtpub.com/application-development/kivy-bluepr... -- it's an OK foundation. (You don't have to get the actual book, the source code is here: https://github.com/mvasilkov/kb)
As evidenced by using Java in the first place, and considering C# for Android at one time ("If Sun doesn’t want to work with us, we have two options: 1) Abandon our work and adopt MSFT CLR VM and C# language, or 2) Do Java anyway and defend our decision, perhaps making enemies along the way")?
Or choosing Groovy-based Gradle as the main build system for Android?
Or not integrating Dart VM into Chrome?
Unlike Microsoft in their evil era - their policy has changed a lot since - they don't seem to be pushing forward their own standards and inventions at all costs, they seem very pragmatic about it.
> Or choosing Groovy-based Gradle as the main build system for Android
If that decision was made by more than just some obscure team buried deep within Google's hierarchy, then why didn't Google start sponsoring the Groovy manager and 2 developers when their funding was axed by Pivotal 2 months ago?
I'm not a mobile developer, so my interests in Python on Android were fairly brief, but the last time I tried, python-for-android was nearly unusably annoying to work with -- a chrooted normal linux with a real Python was miles better.
The `android` module is also rather poor, IIRC it's just some RPC which would be somewhat better off rewritten (a non-blocking version using twisted was a thing I think I started on but never finished).
I've been playing with SL4A (scripting languages for Android), but there doesn't seem to be any active engagement by the project owners.
An actively maintained Python-for-Android with some way to access native Android APIs is great news. I want to poll an Arduino-based web server and send out SMSes if alert thresholds are reached, and a little python script seems just the ticket.
In my view a gaping hole in the Python for Android "stack" is the lack of Tkinter. I know that there are technical hurdles, though I don't understand them.
That looks interesting, since one website said that lack of Tk/Tcl was the obstacle.
I'm not desperate, for now. My interest was piqued when I got interested in Python and Android almost simultaneously, was delighted to see that Android 3 would support Python, and bought an Android 3 tablet.
All of this is just in the name of recreational programming. My weird dream is to be able to write and run my code on any computer. But an un-anticipated side issue is that coding on a tiny screen is no fun at all at my advanced age.
I think I tried it maybe 2 years ago (I think) and back then it really bothered me how big the resulting APKs were. Now, I think, most people don't even care anymore.
The reason I chose to work on this is while you can already create an application using Kivy, it sort of exists in its own world compared to standard Android apps. Because you don't have separate activities, you can't really do stuff like have one of them be launched to handle a specific file or URL (disclaimer: what I'm building can't either yet). There's also the same issues you get with mobile apps that are web apps in an APK, where someone has attempted to reimplement native UI widgets and there's certain behaviours that are not quite right or missing, or you can't use them yet because they haven't been replicated in your environment yet.
So basically what I'm doing is the Python equivalent of Xamarin.Android (https://developer.xamarin.com/guides/Android/ ) built on some of the Kivy tools. The idea is that you'd have the bulk of your logic in cross platform Python and a thin UI layer for any platforms you had. And in the future if someone made a similar thing for iOS, you could build a layer overlying the two of them and get actually native behaviour on both.
Overall I've gotten it to the stage where you can create activities, access some standard UI elements and launch third-party apps via Python code, but like I said, it's still at a pretty early stage.
I'd intended to open source it when it got to a more usable state, as it's pretty much in proof of concept state atm. (bugs ahoy, tests and docs are very lacking, feature coverage is low, setup is a PITA, and the API is too close to the Java API to make for nice Python). These are problems I believe are fixable. If you want to see the current state of it though, it's on https://bitbucket.org/tonyfinn/pydroid , but it's a bit off how far I'd like to be before sharing it.