Can python build android apps?
Asked Answered
T

6

9

I am learning python and i don't know that it will be helpful to me if i want to make android apps.I have read somewhere that python can make android app.But I want to ask you that is it a good option or we should always use andriod studio to make android apps because that is developed particularly for creating android apps.

Tieck answered 26/5, 2015 at 17:42 Comment(1)
If you want headache, sure there are plenty of wrappers and limited help. Go For Android Studio + Java.Pistole
A
13

I'm a core developer of Kivy, which has been mentioned in some of the other answers. I think it's the main option you have for making python apps for android, and it has both advantages and disadvantages.

The main technical disadvantages are (both in my opinion and I think the main problems I see people raise):

  • Startup speed: if the app isn't already running it takes a short time to spin up the python interpreter, up to a few seconds on older devices (or much longer if you code some things badly but that's avoidable), during which time a loading screen is displayed.

  • Lack of native look and feel: Kivy is its own opengl-based graphical framework, so it doesn't look like default android apps (it's customisable but still very hard to perfectly emulate something like that)

  • APK size: Because you have to package the python interpreter, the minimum apk size is about 7MB.

Ther are other potential disadvantages, such as the standard non-java problem of having to catch up the android api when it changes, but I consider these more minor issues, e.g. in this case since you can actually call much of the java api directly from python with pyjnius. I have a blog post about this. Another problem is that kivy's community is small compared to that of the java app community, though it's also quite active.

For some people, one or more of these are immediate or eventual barriers to using Kivy. For others they don't matter or are outweighed by the advantages, and for these reasons there are people using Kivy commercially on Android (and iOS). Personally I'm most interested in the wide space between 'I wrote a simple script' and 'I made a big polished android app', because I think it should be easier than it currently is to bundle simple things as simple apps, but that's just my own reason for using kivy.

Auricula answered 27/5, 2015 at 0:45 Comment(4)
Would it be possible to use libraries like sklearn, signal and other libraries on the android device to process sensor data using kivy ?Bosomy
Pure python libraries should generally work fine. Libraries with compiled components (e.g. sklearn) need compilation recipes - our build tools (python-for-android) include many of these already so you can use e.g. numpy, but sklearn is not currently available this way. It might be possible to make it work, but it could also be tricky to make a recipe for a complex module like this. For sensor data, Kivy has extensive access to the java api via python with pyjnius.Auricula
What stage of development is Kivy in? I read somewhere recently that it is still in alpha development.Concatenate
@Concatenate Kivy is fully released and actively developed, and has been for many years.Auricula
R
2

If the question is,can i run python programs on android then by all means yes. But if the intent is to create a mobile app usibg python then please look at kivy which is yet to support python 3. But outside the love of python ,its best to stick to android studio for native android apps.

Radiotransparent answered 26/5, 2015 at 18:28 Comment(0)
C
2

Chaquopy (https://chaquo.com/chaquopy/) is an option for Python on Android. It is a plugin for Android Studio so could include the best of both worlds - using the Android Studio interface and Gradle, with code in Python.

From the Chaquopy page:

With the Python API , you can write an app partly or entirely in Python. The complete Android API and user interface toolkit are directly at your disposal.

A in-depth review of Chaquopy is at http://blog.codelv.com/2018/02/a-look-at-chaquopy-python-sdk-for.html

The creator of Chaquopy also commented on that review with this:

I think there's room for many different approaches to Python on Android. Chaquopy focuses on giving complete access to all the features of the standard Android API and build tools. (For example, the XML layout file you mentioned was generated using Android Studio's WYSIWYG editor: it didn't have to be written by hand.) But if you want something more Pythonic, or portable to other platforms, then enaml-native or Kivy is the way to go.

CAVEAT: I have not (yet) tested this personally, so I cannot verify how well it works. It is rather complicated.

Additional: It appears to require a license key to run for more than 5 min and requires payment. If you decide to develop open source, there is an open source license which "will always be free of charge."

Concatenate answered 28/11, 2018 at 14:19 Comment(0)
C
1

Android doesn't come with a Python interpreter. So if you want to distribute an application written in Python, you will have to bundle a Python interpreter along with it. In other words, even a "Hello World!" app will be huge.

So yes, it's possible. But not recommended.

Cirillo answered 26/5, 2015 at 18:54 Comment(1)
For context, 'huge' is about 7MB, though that's not all essential and it's possible to go lower.Auricula
S
1

try kivy https://github.com/kivy/python-for-android

It can be used to create android apps.

Sanfordsanfourd answered 26/5, 2015 at 19:26 Comment(0)
T
0

Yes you can using 1- Kivy library 2- install Ubuntu on a versatile machine 3- run buildozer to transfer your main.py file into APK file

Thermit answered 20/6, 2021 at 7:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.