|
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 ?
|
|
asked Sep 19 '08 at 13:21
|
|
|
|
|
|
How is that post well ranked ? It's 4 lines long and there is like 3 answers ! I guess Pytho on Android has a huge sex appeal...
–
e-satis
Jun 10 '09 at 8:17
|
|
|
|
I mean the contrary. Given the little content of this post, if it's well ranked, it must be a huge expectation. I strongly hope the best for this project, I'm myself more a pythonista than a Java guy and coding Android with this language would sky rock the prototyping phase.
–
e-satis
Jun 10 '09 at 12:51
|
|
@user457015 I think you should really read up on how modern JVMs are implemented, they're nowhere near to "scripting" or "interpretation" by now. If anything, Java is now only ~ 10-25% slower than well / perfectly written C/C++ code. And there's way less place to screw up writing in Java...
–
TC1
Feb 14 '12 at 15:39
|
show 5 more comments
|
|
How about Kivy?
http://
Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps.
Kivy runs on Linux, Windows, OS X, Android and iOS. You can run the same [python] code on all supported platforms.
Kivy Showcase app
https://play.google.com/store/apps/details?id=org.kivy.showcase
|
|
answered Nov 18 '11 at 21:49
|
|
|
|
|
|
|
|
Works very nicely, builds somewhat large packages. But the source code is actually on the device, so you can inspect and edit on site if need be.
–
relet
Dec 19 '11 at 13:39
|
|
|
|
|
show 9 more comments
|
|
|
answered Jun 10 '09 at 5:24
|
|
|
|
True, but they have to have ASE installed, it's not a solution that lets you write an Android app in python without anything already installed (normal user will be all "wtf is this ASE thing?)
–
Stuart Axon
Nov 26 '10 at 18:30
|
|
|
|
|
|
|
|
You can write apps, package them, and even sell them on Play Store if you like, with SL4A now days. It's come along well since the comments above were posted. If you want Python on Android, then PY4A, which runs on SL4A is probably the best choice.
–
Carl Smith
Mar 9 '13 at 17:53
|
add comment
|
|
YES!
An example via Matt Cutts -- "here’s a barcode scanner written in six lines of Python code:
import android
droid = android.Android()
code = droid.scanBarcode()
isbn = int(code['result']['SCAN_RESULT'])
url = "http://books.google.com?q=%d" % isbn
droid.startActivity('android.intent.action.VIEW', url)
|
|
answered Jun 10 '09 at 5:13
|
|
|
|
|
|
s/YES/meh. maybe/ ...it's extremely limited. anything graphical or multi touch? a big NO.
–
gcb
Oct 23 '10 at 9:09
|
|
@gcb you can't use the normal android widget set, but you can use "webviews" (which is what the native gmail application uses, for example).
–
gdw2
Mar 16 '12 at 16:10
|
|
golfed: import android as a;d=a.Android();d.startActivity('android.intent.action.VIEW',"http://books.googl??e.com?q=%d"%int(d.scanBarcode()['result']['SCAN_RESULT']))
–
Alex L
Dec 28 '12 at 6:20
|
add comment
|
|
"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.
|
answered Jan 28 '11 at 12:18
|
|
|
|
Several aspects were broken on my Droid X (buttons, or touchscreen, can't remember), so I didn't get very far with this route.
–
gdw2
Oct 5 '11 at 21:56
|
add comment
|
|
There's also SL4A written by a Google employee.
|
answered May 26 '11 at 9:21
|
|
|
add comment
|
|
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:///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).
|
|
answered Oct 12 '11 at 13:49
|
|
|
|
Impressive. +1 for this. Not accepted because you can't possibly write anything for the public with this.
–
e-satis
Oct 13 '11 at 14:14
|
|
If you mean you can not do graphic apps with it, you most definitely can, of course, more work is needed. I actually use this port combined with SDL 1.3, it's not trivial to go from the python interpreter to an interactive app, but it can be done.
–
gabomdq
Oct 14 '11 at 2:38
|
add comment
|
|
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.
|
answered Nov 1 '08 at 20:29
|
|
|
|
There is not a single java word on an Android phone, it's compiled to byte code during the packaging process. Speed is not the issue : Google could provide tools producing the right byte code from a python code (like for Jython). BTW, Dalvik is not the Java VM so this is not about Java VS Python.
–
e-satis
Nov 2 '08 at 18:20
|
|
|
|
|
add comment
|
|
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.
|
|
answered Sep 19 '08 at 13:26
|
|
|
add comment
|
|
Check out this blog here that explains how to install and run python and a simple webserver written in python on Android.
http://www./?p=113
|
answered Dec 7 '10 at 21:46
|
|
|
|
Very nice. If you can run a server, you may be able to run django. Django demo on an android tablet anyone ?
–
e-satis
Dec 8 '10 at 11:02
|
|
|
|
@gdw2 im curious how you managed to get web2py to run here? using sl4a and using python to run webpy.py to start the server? When you do this though, you need to launch the browser separately. And im sure you would have to make the end users install sl4a as well.
–
luckysmack
Sep 5 '12 at 20:12
|
|
@luckysmack If I recall, I only started it using the terminal (ssh'd in to my phone). I never went so far as to package it into an app (with its own icon).
–
gdw2
Sep 7 '12 at 4:32
|
add comment
|
|
SL4A does what you want and is actively developed. You can install it on your droid easily from their site, and don't need root.
It supports a range of languages, Python support is currently for version 2.6, but the owner, Robbie, is personally working on Python3.
SL4A scripts have a library available for each supported language that gives you an interface to the Android API as a single Android object:
import android
droid = android.Android()
# say "hello world" using the text to speech facade
droid.ttsSpeak('hello world')
Each language has the pretty much the same API, and you can even access the device with JavaScript inside a webview or something:
var droid = new Android();
droid.ttsSpeak('hello from js');
SL4A URL:
http://code.google.com/p/android-scripting/
Update
- Python3 is out and works well, but Python2.6 is the best supported version.
- You can also now do native Android user interfaces.
|
|
answered Mar 19 '12 at 15:45
|
|
|
add comment
|
|
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.
|
answered Jan 6 '12 at 14:34
|
|
|
|
|
|
UPDATE: I've been using CherryPy and ws4py on SL4A with Python3 for a few weeks now, with no problems there either.
–
Carl Smith
Sep 19 '13 at 2:28
|
add comment
|
|
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.
|
answered Jan 9 '12 at 4:46
|
|
|
|
|
|
@e-satis: Thanks for your comment. I don't see which answer I'm duplicating. I can only guess that you think PFA is the same as Kivy. Though it's hosted under the Kivy project, you don't even have to use Kivy to use PFA.
–
gdw2
Jan 9 '12 at 22:46
|
|
Check @tito's deleted answer at the bottom point to PFA. Plus, there is little interest is running PFA without kivy since it's the only toolkit you got.
–
e-satis
Jan 10 '12 at 0:55
|
|
It's not because kivy is currently the only toolkit available (some people are working to intregrate others) than it's a duplicate. Please consider the others options as-it, and not merge all into one post :|
–
tito
Mar 16 '12 at 14:34
|
add comment
|
|
I use the qpython app, it has a editor, a console, and you can run your python programs with it, the app is free, here is the link http:///
|
answered Jun 12 '13 at 19:46
|
|
|
add comment
|
|
You can run your python code using sl4a. sl4a supports Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell script.
You can learn sl4a Python Examples
|
answered Mar 11 '13 at 9:36
|
|
|
add comment
|
|
There is a wonderful project called the Scripting Layer for Android (SL4A) that is bringing scripting languages to the Android platform and providing a working alternative to Java development.
To get started, you need a copy of the Android SDK running on your computer, and you need a Java VM. Although you aren't going to program your Android app with Java, you still need a Java runtime upon which to execute the Android emulator, which is part of the SDK. The inclusion of the Android emulator gives you a sandboxed testbed to play in while you create your app.
Then you need to download and install Sl4A. You can download a copy from here. http://code.google.com/p/android-scripting/
|
answered Sep 10 '12 at 5:38
|
|
|
|
|
|
You don't need to install anything on your computer. I think you're thinking of Python4Android27. SL4A can use ADB and other tools, because they're handy, but it works fully without them.
–
Carl Smith
Feb 13 '13 at 1:33
|
add comment |
Yes you can use kivy
This is a nice cross platform python framework which works for Android, Win7, Linux, Mac. iOS is possibile but very trivial as Apple doesn't allow scripting.
And for Android Google provides something called ASE (Android Scripting Environment) which allows scripting languages (Python included) to run on Android. More details here
For iOS Python development would be to embed a Python interpreter
into you app and distribute your Python script with it (so to play
nicely with Apple rules). In this case your Python application would be a
Python interpreter which is packaged with your script and runs it
automatically. As I've said - it ain't pretty
You can check details Here
Hope it helps you.
|
|
answered May 5 '13 at 7:15
|
|
Not out of the box. The final product needs to be
compiled (iOS) or in bytecode (Android). Since it may be possible to
convert Python code to Objective-C or something in between it might be
possible.
See Kivi, the previous tread referenced it. This allows you to write you app in Python but probably uses a common wrapper, that Kivi provides, to run Pyton.
Please not that code written in Objective-C (iOS) or Java (Android)
will always be faster than middleware like Kivi or Phonegap. Unless the
one developing is very bad at writing any of those native languages....
|
|