在Kivy虚拟机中用Buildozer构建时缺失AndroidManifest.tmpl.xml
jinja2.exceptions.TemplateNotFound: AndroidManifest.tmpl.xml in Buildozer for Kivy Android Apps Let's fix that annoying jinja2.exceptions.TemplateNotFound: AndroidManifest.tmpl.xml error you're hitting when building your Kivy Android app with Buildozer in the Kivy VM. Here's what's going wrong and how to fix it step by step:
1. Fix your buildozer.spec manifest configuration
Looking at your error log, the build command includes --intent-filters /home/kivy/Desktop/sf_kopec/AndroidManifest.tmpl.xml—that's the core issue! You've accidentally set your manifest template path in the android.manifest.intent_filters field instead of the correct dedicated field for templates.
- If you want to use a custom AndroidManifest template:
Open yourbuildozer.specfile and set this line (make sure the template file exists in your project root folder):android.manifest.template = AndroidManifest.tmpl.xml - If you don't need a custom template:
Just delete theandroid.manifest.intent_filtersline entirely. Buildozer will automatically use its default manifest template from the python-for-android toolchain—no manual setup needed.
2. Verify the template file (if using a custom one)
If you're sticking with a custom manifest template:
- Confirm
AndroidManifest.tmpl.xmlis actually present in your project root directory (the same folder where you ranbuildozer init). - Double-check the file name matches exactly what's in your
buildozer.spec—case sensitivity matters on Linux-based systems like the Kivy VM.
3. Clear Buildozer's cache and rebuild
Old cached build files can sometimes cause weird configuration conflicts. Run these commands to start fresh:
buildozer android clean buildozer android debug
4. Ensure your python-for-android toolchain is complete
If the default template is missing (unlikely but possible), updating the python-for-android toolchain can fix it:
pip install --upgrade python-for-android
You can also enable automatic SDK/toolchain updates in your buildozer.spec by adding:
android.sdk_update = True
Then rebuild to let Buildozer fetch any missing files.
Why this happened
The error occurs because Buildozer was told to treat your manifest template file as an intent filter rule (via the --intent-filters flag). Intent filters are for things like letting your app open specific URLs or file types—not for specifying manifest templates. When Buildozer tried to process this as an intent filter, it couldn't find the expected template structure, hence the TemplateNotFound error.
内容的提问来源于stack exchange,提问作者Jakub Bláha

