Use Kivy to package the python program as an apk file,

Source: Internet
Author: User

Use Kivy to package the python program as an apk file,

1. Overview

KivyYesPythonThe cross-platform open-source application development framework is available on the official website.
ItPythonProgram Package as AndroidapkInstallation File. The following is used in windows.

Many things will be downloaded during installation and configuration to ensure stable access.InternetIn addition, we recommend a video tutorial: Youtube

2. Steps

First, installPythonMy version isPython 2.7.13And then installKivyPackage:

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.pyTest:

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 MachineVirtualBoxThis 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.pyCopy to this folder, and then copy to the backup desktop in the virtual machine.

Then open the terminal (cd to the desktop) and executebuildozer initCommand, which will be generated on the desktopbuildozer.specConfiguration file:

Then use the commandgedit buildozer.specTo edit the file.sudo apt-get install geditTo 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 debugAnd then download a lot of things, suchAndroid SDK,Android NDKAnd 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 downloadedbinTheapkFile, 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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.