For more on packaging your app for Android, check out:
Package Your App for Android
00:00 Packaging Your App for Android. Packaging your application for both Android and iOS will be shown as an example in this course. But you should be aware that the creation of mobile apps using Kivy is a moving target for multiple reasons.
00:15 Building for both platforms involves using a number of third-party software libraries and tools, and these change regularly. This can mean one or more parts of the process will be different when you attempt it. In addition, the mobile platforms themselves are regularly updated, which can mean that the tools need new versions to work with the latest and greatest OS that’s available. But with these potential issues in mind, let’s move on to take a look at how to package your Kivy app for Android.
To accomplish this, first you’ll need to install a package called
pip. Note that it is possible to achieve this on Windows, but involves using the WSL subsystem, and you won’t have direct access to an Android device from it, so this falls outside the scope of this course. On macOS and Linux, the path is more straightforward.
01:06 Firstly, you install Buildozer and Cython.
01:34 You’ll also need to install a Java runtime. The one you install will depend on your operating system and architecture. The Java development kit needed for use with Buildozer must be the correct one, or the build process will fail.
On-screen, you can see the installation selection of
openjdk-11, which works with the version of Buildozer used for this build.
Next, create a new folder and navigate to it in your terminal. Once you’re there, you’ll need to run the following command. This will create a
buildozer.spec file that you’ll use to configure your build.
02:24 For this example, you can edit the first few lines of the spec file as seen on-screen.
02:45 Feel free to browse the rest of the file to see what else you can change.
At this point, you are almost ready to build your application. First, copy your calculator application into your new folder and rename it to
This is required by Buildozer. If you don’t have the file named correctly, then the build will fail. Now you can run the
buildozer command, as seen on-screen.
03:17 The build step can take a long time. Fifteen to twenty minutes is not unusual. Depending on your hardware, it may take even longer, so feel free to grab a drink and check out some other Real Python tutorials while you wait.
03:31 Buildozer will download whatever Android SDK pieces it needs during the build process.
If everything goes according to plan, then you’ll have a file named something such as
kvcalc-0.1-debug.apk in your
The next step is to connect your Android phone to your computer and copy the
.apk file to it. You can then open the file browser on your phone and find and open the
04:19 Android should ask you if you’d like to install the application. You may see a warning since the app was downloaded from outside Google Play, but you should still be able to install it.
04:32 On-screen, you can see the calculator running on my phone.
04:48 The Buildozer tool has many other commands you can use. Check out the documentation to see what else you can do. If you need more fine-grain control, then you can also package the app using Python-for-Android, which is used under the hood of Kivy. You won’t be covering this here, but if you’re interested, check out the project’s Quickstart.
05:12 In the next section, of course, you’ll take a look at packaging your app for iOS.
Become a Member to join the conversation.