Home  >  Article  >  Backend Development  >  How to write Android programs in python

How to write Android programs in python

anonymity
anonymityOriginal
2019-06-18 10:45:067631browse

We use kivy to develop Android APP. Kivy is a set of open source frameworks specially used for cross-platform rapid application development. It is written in Python and Cython. It has very good support for multi-touch, which not only allows developers to complete the application quickly With simple interactive prototyping and support for code reuse and deployment, it is definitely an amazing NUI framework.

How to write Android programs in pythonBecause it is cross-platform, you only need to write the code once to generate Android and iOS APPs at the same time, which is cool.

Take everyone to write a Hello world

kivy installation
Environment description: The author is using Python2.7.10
Here we only introduce the windows platform installation
Reference for all platforms: https://kivy.org/#download

Update pip, setuptools

python -m pip install –upgrade pip wheel setuptools

Then install the required dependencies

python -m pip install docutils pygmentspypiwin32 kivy.deps.sdl2 kivy.deps.glew \ 
kivy.deps.gstreamer –extra-index-url https://kivy.org/downloads/packages/simple/

It is worth noting that the above Android needs to access Google, so please bring your own ladder, and the kivy.deps.gstreamer package is relatively large (95MB) and can be installed locally alone,
Then install kivy

python -m pip install kivy

At this point, the installation is complete. It is worth noting that the 64-bit system does not have virtualization support enabled. An error will be reported when importing kivy. If it is 64-bit Just set the machine's BIOS and enable virtualization support.
Note: This is just the running environment of kivy, so that I can debug it directly on the windows machine. We will talk about how to compile the code into an APK file later.

If kivy is in python, it should be able to be imported.

According to world practice, let’s say “hello”.
Create a new .py filehelloworld

from kivy.app import App from kivy.uix.button importButton
class TestApp(App): def build(self): return Button(text=’Hello,kivy’)
TestApp().run()

The above is the detailed content of How to write Android programs in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn