You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何通过GitHub将Kivy项目打包为APK文件?已尝试Bulldozer在VM及RPI操作但持续报错

Hey there! I’ve been through the same struggle with Kivy to APK packaging, so let me walk you through the most reliable method using GitHub Actions (since you mentioned wanting to leverage GitHub for this)—it’s way more consistent than trying to get Bulldozer working on VMs or Raspberry Pi.

How to Package a Kivy Project into APK Using GitHub Actions

Prerequisites

  • Your Kivy project is pushed to a GitHub repository (make sure it has a proper main.py, buildozer.spec, and all required assets like images or .kv files)
  • Basic familiarity with GitHub’s interface and workflow files

Step 1: Nail Down Your Buildozer Spec

First, you need a correctly configured buildozer.spec file in your repo root. If you don’t have one, generate it locally first (even if your local build failed, the spec itself is still usable):

buildozer init

Edit the spec with these key settings (tweak values to match your project):

[app]
title = YourAppName
package.name = yourapp
package.domain = org.yourdomain
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 0.1
requirements = python3,kivy
android.api = 33
android.ndk = 25b
android.sdk = 24
android.buildtools = 30.0.3
android.use_aapt2 = True

Pro tip: Locking in specific versions for API, NDK, SDK, and buildtools avoids the version mismatches that often break local builds.

Step 2: Create a GitHub Actions Workflow

In your repo, make a new directory .github/workflows and add a file named build-apk.yml with this content:

name: Build Kivy APK
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.10'

      - name: Install Buildozer dependencies
        run: |
          sudo apt update
          sudo apt install -y git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
          pip install --upgrade pip
          pip install buildozer cython==0.29.33

      - name: Build APK
        run: buildozer android debug

      - name: Upload APK artifact
        uses: actions/upload-artifact@v4
        with:
          name: your-app-apk
          path: bin/*.apk

Why this works: GitHub’s Ubuntu runners have clean, standardized environments—no missing libraries or conflicting versions that plague custom VMs or Raspberry Pi (which isn’t officially supported for Buildozer builds anyway).

Step 3: Fix Common Errors You Might’ve Faced

If Bulldozer failed on your VM/RPi, here’s why this method avoids those headaches:

  • Environment inconsistencies: GitHub’s runners are reset every time, so you don’t have to troubleshoot leftover dependencies or broken configs.
  • Bulldozer wrapper limitations: Using raw Buildozer gives you more control. If you still hit errors:
    • Double-check your buildozer.spec for typos (e.g., wrong package names, missing requirements like pillow if you use images)
    • Ensure all assets are in the directory specified by source.dir
    • If you get a "missing module" error, add the required package to the requirements line in your spec

Step 4: Grab Your APK

After pushing the workflow file to GitHub, head to your repo’s Actions tab. You’ll see the build run automatically. Once it finishes successfully, click into the run, scroll down to the "Artifacts" section, and download your APK file.


内容的提问来源于stack exchange,提问作者GCIreland

火山引擎 最新活动