suppose I have the simplest program that can be done with kivy:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
In addition to seeing it on my desktop computer, I would like to see it on my mobile. What steps should I take?
I recommend that you look at the Kivy documentation about it:
Kivy- Create a package for Android
To summarize a bit, to create an apk you have two options, use Buildozer or directly python-for-android . Creating the app with Buildozer is simple and fast. The problem is that it only works under Linux systems at the moment. If you have access to a Linux system (Ubuntu, Debian, Fedora, etc) you can follow the steps described in the documentation. If not you can use The Kivy Android Virtual Machine and use it on windows with VirtualBox. It is an Ubuntu based distro with everything you need to build the apk with Buildozer (Android SDK, Android NDK, python-for-android, kivy, python, etc).
However, since you are just starting out with Kivy, I recommend that you use the Kivy Launcher instead . You download it from GooglePlay on your Android phone and once installed, it allows you to launch Kivy applications from your Android. When you have your application finished, it is best to create the apk with Buildozer, but while you develop it or even to use it on a personal level, this option is very good since it allows you to modify the app by simply copying and pasting the files (.py, .kv, images , etc) on the phone without having to recompile the apk.
To use Kivy Launcher you must:
main.py
.You need a text file with the configuration of your app, called
android.txt
and that must contain at least:Now you go to your phone, look for the folder
/sdcard/kivy/
and create another folder with the name of your application inside. Inside it you paste the two previous files (the whole app actually: .py modules, kivy language files, icons, videos, etc go here too).Now you simply open the Kivy Launcher app and a list of applications will appear (a few examples come with the installation). You select yours and it should run fine if everything is correct.
For your simple example:
You create a file
android.txt
that contains something like this:Save the code you provide as
main.py
.You connect the phone to the PC, look for the kivy folder, create a new folder called MyApp inside and put the two previous files inside.
You go to your phone and launch Kivy Launcher, select MyApp and that's it:
You can use pydroid that will serve as a Python interpreter and you can test your apps there without compiling or needing anything... simple ?