Skip to main content
Top

2019 | Book

Building Android Apps in Python Using Kivy with Android Studio

With Pyjnius, Plyer, and Buildozer

insite
SEARCH

About this book

Start building Python-based Android applications using Kivy with Android Studio. Through in-depth examples, this book teaches you everything you need to create your first Android application in Python and publish on Google Play.

Building Android Apps in Python Using Kivy with Android Studio takes you through the basics of Kivy by discussing its application structure, widgets, and event handling. The KV language is then introduced for separating the logic and GUI by adding widgets within a KV file. You will then learn how to utilize Android camera using Kivy, build the HTTP server using Flask, and create and manage multiple screens to help you design your own applications. Through detailed step-by-step instructions, you will create your first multi-level cross-platform game that includes animation and sound effects. Following this, the process of converting the Kivy application into an Android application using Buildozer and Python-4-Android is covered in detail. You will then learn how to edit the generated Android Studio project into Android Studio by adding extensions to the original application. The widgets added in Kivy could be handled within Android Studio. Moreover, Android views could be added to enrich the Kivy application. The resulting Android application created with Kivy can be hosted on Google Play to download and install as a regular Android application.

At the end, this book will give you the basic knowledge of Kivy needed to build cross-platform Android applications, produce an Android Studio project, and understand how it all works in detail.

What You Will Learn

Build cross-platform applications from scratch using Kivy in detailCreate a cross-platform interactive multi-level game from the ground upExamine the pipeline of building an Android app from the Python Kivy appUnderstand the structure of the Android Studio project produced by KivyRecognize how to extend the application within Android Studio by adding more Android views to the application main activity.

Who This Book Is For

Python developers with no previous experience in Kivy who are looking to create their first Android application completely in Python.

Table of Contents

Frontmatter
Chapter 1. Preparing Kivy for Android Application Development
Abstract
This chapter introduces the Kivy framework for building cross-platform applications in Python. It starts by showing you how to prepare the Kivy development environment on a desktop computer. We will create a simple Kivy desktop application. We will also install Buildozer and use it to build an Android Studio project from the desktop app. An APK file is created, which can be installed on an Android device or deployed on Google Play after being signed.
Ahmed Fawzy Mohamed Gad
Chapter 2. Using KV Language for Separation of Logic and GUI
Abstract
In the previous chapter, we prepared the Kivy development environment and created a very simple desktop application. Then we installed Buildozer to build mobile applications. As we previously discussed, the tools and requirements for a successful build can be installed automatically using Buildozer or can be downloaded offline and linked. By preparing the Android SDK, NDK, and the required Python libraries, we can successfully build an Android application that uses the same Python code as the desktop application. This is because Kivy is a cross-platform library.
Ahmed Fawzy Mohamed Gad
Chapter 3. Sharing Android Camera to an HTTP Server
Abstract
In the previous two chapters, we prepared the Kivy environment for developing desktop applications. After making sure everything was working as expected, we installed Buildozer to build the Android applications. The first application we created in the book was very simple; a single label widget displayed some text. After that, more widgets were added to the application using layouts. The button press action was handled using on_press. A nested widget tree was created, which made debugging much more complicated. For that reason, the KV language was introduced for structuring the widget tree and separating the GUI from the Python logic.
Ahmed Fawzy Mohamed Gad
Chapter 4. Creating and Managing Multiple Screens
Abstract
In the previous chapter, we accessed the Android camera using the Camera widget. Kivy canvases were introduced to adjust the camera rotation. In order to limit the effect of a given canvas instruction to just some widgets, the PushMatrix and PopMatrix instructions were discussed. After that, we created an Android Kivy application to continuously capture images and send them to the Flask server, which displays them in an HTML page.
Ahmed Fawzy Mohamed Gad
Chapter 5. Building Your First Multi-Level Game in Kivy
Abstract
The previous chapter introduced Kivy so that we could start building cross-platform applications. As a way of applying concepts, we created an Android application that captures images and continuously sends them to a Flask server.
Ahmed Fawzy Mohamed Gad
Chapter 6. Completing and Publishing Your First Game
Abstract
In the previous chapter, we started developing a multi-level cross-platform game in which a character moves, using animation, according to the touch position. The player’s job is to collect a number of uniformly distributed coins on the screen. A monster tries to attack the player in order to kill it. When a collision occurs between the player and the monster, the player dies and the level ends. Until the end of the previous chapter, the game just had a single level.
Ahmed Fawzy Mohamed Gad
Chapter 7. Working with Kivy Projects from Android Studio
Abstract
When a Python developer knows that it is possible to create Android apps using Python, one of the first questions to be asked is whether Python can develop rich Android applications like the ones developed in Android Studio using native Android languages (i.e. Java). Unfortunately, the answer is that Python is limited in its capabilities compared to Java when building Android (mobile) applications. But the good news is that there are ways to enrich the Android applications created in Python.
Ahmed Fawzy Mohamed Gad
Backmatter
Metadata
Title
Building Android Apps in Python Using Kivy with Android Studio
Author
Ahmed Fawzy Mohamed Gad
Copyright Year
2019
Publisher
Apress
Electronic ISBN
978-1-4842-5031-0
Print ISBN
978-1-4842-5030-3
DOI
https://doi.org/10.1007/978-1-4842-5031-0

Premium Partner