Use Kivy to package the python program as an apk file,
1. Overview
Kivy
YesPython
The cross-platform open-source application development framework is available on the official website.
ItPython
Program Package as Androidapk
Installation File. The following is used in windows.
Many things will be downloaded during installation and configuration to ensure stable access.Internet
In addition, we recommend a video tutorial: Youtube
2. Steps
First, installPython
My version isPython 2.7.13
And then installKivy
Package:
There are detailed installation steps for the Kivy package on the official website. Follow these steps to install the Kivy package.
Then, write a simple program.main.py
Test:
import kivykivy.require('1.9.1')from kivy.app import Appfrom kivy.uix.button import Buttonclass test(App): def build(self): return Button(text='hello world') if __name__ == '__main__': test().run()
Run:
If the operation is successful, the development environment is basically okay. Then the following is how to package the programapk
.
First, you need to install the Virtual MachineVirtualBox
This is okay, and it will soon be installed. Then, Kivy officially created the image of the Virtual Machine (very considerate), which can be run directly after download, saving a lot of trouble ., Or go to the official website to download:
After downloading and unzipping the package, Open VB and load the Virtual Machine file in the folder, and then run (login password kivy ):
After entering the system, you need to configure the environment. Official Guide
First, add a shared folder to the system to share the file with windows. In the VB device> shared folder option, the file is configured as follows:
Then, we create a folder in a path under windows, select it as a shared folder, and select automatic mount:
Then restart the virtual machine to access the Shared Folder:
After setting the shared folder, you can set the previously written test programmain.py
Copy to this folder, and then copy to the backup desktop in the virtual machine.
Then open the terminal (cd to the desktop) and executebuildozer init
Command, which will be generated on the desktopbuildozer.spec
Configuration file:
Then use the commandgedit buildozer.spec
To edit the file.sudo apt-get install gedit
To install)
Basically, you don't need to change anything. The source. dir should be noted. This is what we just put on the desktop.main.py
.
Then runbuildozer android_new debug
And then download a lot of things, suchAndroid SDK
,Android NDK
And so on, and they need to access the Internet and build a self-built ladder. This process took a long time, and I thought it was a problem for a while. Then I slept at noon and it was about ^.
After the configuration is automatically downloadedbin
Theapk
File, you can try it on your phone.
Then the basic process is like this ^. You can go to the official website for details. I completed the process on the official website.
Finally, we recommend a MIT developed by the rapid production of Android app website, http://appinventor.mit.edu/explore/