Kivy Python C Extension Template

For Detailed Breakdown see, Documentation

TL;DR

  1. A simple C Extension to return a string

  2. Build it using setup.py / setup.cfg

  3. Import C Extension in Kivy / Python

  4. Create a simple Recipe for Compiled Component for Buildozer / P4A

  5. Edit Buildozer :

    #In Requirements make sure to mention the C Extension Module
    requirements = python3,kivy,custom_lib

    #Specify the path for the setup.py / setup.cfg for local C Extension Module
    requirements.source.custom_lib = ./custom_lib/

    #Specify the path for Recipe for local C Extension Module
    p4a.local_recipes = ./python-for-android/recipe

    are the main ones to edit based on the paths in buildozer.spec

  6. Build with buildozer android debug deploy run logcat

    Note : I've used custom ndk, sdk paths in spec file