Buildozer keeps using old Android API version despite configuration changes

I’m having trouble using buildozer 1.3 to create an Android application from Python code. My issue is that it always compiles with Android API 27, even if I specify a different version in my buildozer.spec file.

The build process appears to work correctly, and the app is generated without issues. However, when I attempt to upload it to the Google Play Store, it’s rejected because API 27 is outdated. The console output indicates that API 31 is being utilized during the build process, but the final APK still shows API 27.

I’ve tried a variety of solutions, including a complete reinstallation of buildozer, setting up a new WSL environment from scratch, and even removing the buildozer.spec file to confirm I was editing the correct one. Unfortunately, none of these efforts have resolved the problem.

Here are the relevant details from my console output during the build:

[INFO]:    Will compile for the following archs: armeabi-v7a, arm64-v8a
[INFO]:    Found Android API target in $ANDROIDAPI: 31
[INFO]:    Available Android APIs are (27, 30, 31)
[INFO]:    Requested API target 31 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK: /home/user/.buildozer/android/platform/android-ndk-r21d
[INFO]:    Found NDK version 21d

The settings in my buildozer.spec file are as follows:

[app]
title = My Test App
package.name = mytestapp
package.domain = dev.myapps
source.dir = .
version = 0.1
requirements = python3,kivy,plyer,android
orientation = portrait

[buildozer]
fullscreen = 0
android.api = 31
android.minapi = 21
android.ndk = 21d
android.ndk_api = 21
android.archs = arm64-v8a, armeabi-v7a

Can anyone explain why the final APK is still using API 27 when everything seems to be set up correctly?

i had that prob too! make sure u check ur environment vars, sometimes they point to the wrong paths. delete those old cache files in .buildozer & give it another shot. it helped me out a lot when i faced the same issue.

This happened to me too. Check your android.gradle section in buildozer.spec - even if your main android.api setting looks right, gradle configs can override the API level during build. I found my project was using an old gradle template that hardcoded API 27. Add android.gradle_dependencies = and android.add_src = entries to clear any conflicting build configs. Also check for custom gradle files in your project directory that might mess things up. Once I cleaned those up, the build finally used my API 31 setting and passed Google Play’s requirements.

Have you checked the actual compiled APK target SDK version with aapt or bundletool? Build logs sometimes show one thing, but the manifest compiles differently. I’ve seen buildozer have mismatches between what python-for-android reports and what’s actually in the final APK manifest. Run aapt dump badging your_app.apk and check the targetSdkVersion line. If it’s still showing 27, the problem’s probably in your python-for-android setup, not buildozer. I had to nuke my entire .buildozer folder and force a fresh download of all build tools. The trick was making sure the android SDK platform-tools matched the API level I wanted to target.