You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Buildozer执行Release命令时崩溃,添加图标后构建失败求助

Fix: Buildozer Release Build Fails with Aapt2Exception (PNG Signature Issue)

Hey there, let's tackle this frustrating issue you're facing. The core problem here is that Android's Release build uses far stricter resource validation than Debug mode—your icon.png is either not a properly formatted PNG, has the wrong file extension, or got corrupted somewhere in the process. Here's how to fix it step by step:

1. Validate Your Icon File is a True PNG

First, eliminate the most common culprit: a bad icon file.

  • Open icon.png with a proper image editor (like GIMP, Photoshop, or even Windows Paint) to confirm it displays correctly.
  • Re-export it as a standard PNG file—don't just rename a JPG or other format to .png! Aim for a source resolution of at least 512x512 (Buildozer will auto-generate all required smaller sizes from this).
  • For quick terminal validation:
    • On Linux/macOS, run file icon.png—you should see output like icon.png: PNG image data, 512 x 512, 8-bit/color RGBA, non-interlaced.
    • On Windows, right-click the file > Properties > Check that "Type of file" explicitly shows "PNG image".

2. Double-Check Buildozer.spec Configuration

Make sure your spec file points to the correct, fixed icon:

  • Locate the line starting with icon.filename and confirm it targets your valid PNG, e.g.:
    icon.filename = icon.png
    
  • Ensure the icon file lives exactly where the spec expects it (usually your project's root directory).

3. Clear Buildozer Cache and Rebuild from Scratch

Old cached resources can cause weird, hard-to-track issues. Wipe them and start fresh:

  • Run this command to clean all build artifacts:
    buildozer android clean
    
  • Trigger a new Release build:
    buildozer android release
    

4. Inspect Auto-Generated Resources (If Problems Persist)

If the build still fails, check the icon files Buildozer generates:

  • Navigate to .buildozer/android/platform/python-for-android/dists/[your-project-name]/res/mipmap-* folders.
  • Open each icon to confirm they're valid PNGs. If any look corrupted, replace them manually with resized versions of your fixed source icon, then re-run the build.

If all other steps fail, you can bypass AAPT2's strict PNG checks (this is a workaround, not a permanent fix). Add this line to your Buildozer.spec:

android.add_gradle = android.buildTypes.release.aaptOptions.cruncherEnabled = false

This skips PNG optimization/validation, but might lead to other resource issues later—only use this if you've exhausted all other options.

The root cause is almost always a non-standard or corrupted PNG file. Debug mode lets these slip through, but Release mode enforces strict compliance with Android's resource rules. Fixing the icon file itself will resolve the mergeReleaseResources failure.

内容的提问来源于stack exchange,提问作者İbrahim Hakkı

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:32:59