例外:SDL2:无法加载图像 - 在 android 上运行 kivy apk 时
Posted
技术标签:
【中文标题】例外:SDL2:无法加载图像 - 在 android 上运行 kivy apk 时【英文标题】:Exception: SDL2: Unable to load image - When running kivy apk on android 【发布时间】:2022-01-24 04:38:36 【问题描述】:我创建了这个非常简单的应用程序,只是作为一个演示。然后为了在 android 上运行它,我将它转换为带有 buildozer 的 APK。转换成功,但是当我尝试运行我的应用程序时,它崩溃了。我尝试用 adb logcat 调试它并得到了这个错误-
12-23 10:15:00.913 22282 22454 I python : Traceback (most recent call last):
12-23 10:15:00.913 22282 22454 I python : File "/content/.buildozer/android/app/main.py", line 82, in <module>
12-23 10:15:00.913 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/app.py", line 950, in run
12-23 10:15:00.914 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/base.py", line 582, in runTouchApp
12-23 10:15:00.914 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/base.py", line 347, in mainloop
12-23 10:15:00.914 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/base.py", line 395, in idle
12-23 10:15:00.914 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/lang/builder.py", line 793, in sync
12-23 10:15:00.915 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/lang/builder.py", line 69, in call_fn
12-23 10:15:00.915 22282 22454 I python : File "kivy/graphics/instructions.pyx", line 366, in kivy.graphics.instructions.VertexInstruction.source.__set__
12-23 10:15:00.915 22282 22454 I python : File "kivy/graphics/context_instructions.pyx", line 430, in kivy.graphics.context_instructions.BindTexture.source.__set__
12-23 10:15:00.915 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/core/image/__init__.py", line 561, in __init__
12-23 10:15:00.916 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/core/image/__init__.py", line 754, in _set_filename
12-23 10:15:00.916 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/core/image/__init__.py", line 460, in load
12-23 10:15:00.916 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/core/image/__init__.py", line 223, in __init__
12-23 10:15:00.917 22282 22454 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/popcat/kivy/core/image/img_sdl2.py", line 47, in load
12-23 10:15:00.917 22282 22454 I python : Exception: SDL2: Unable to load image
12-23 10:15:00.917 22282 22454 I python : Python for android ended.
我不知道为什么会这样。有人可以帮我吗?
【问题讨论】:
请添加最小可重现示例 【参考方案1】:在代码中添加这个似乎可行-
import os
os.environ['KIVY_IMAGE'] = 'pil,sdl2'
【讨论】:
以上是关于例外:SDL2:无法加载图像 - 在 android 上运行 kivy apk 时的主要内容,如果未能解决你的问题,请参考以下文章