带有 Buildozer 的 Kivy pyjnius - 将 jnius 添加到应用程序会导致它在启动后崩溃
Kivy pyjnius with Buildozer - Adding jnius to the app causes it to crash after starting it
将这些代码行添加到我的 kivy 应用程序后,当我在我的 android 4.4.4 上启动它时,该应用程序立即崩溃
from jnius import autoclass
try:
Environment = autoclass('android.os.Environment')
sdpath = Environment.get_running_app().getExternalStorageDirectory()
# Not on Android
except:
sdpath = App.get_running_app().user_data_dir
我检查了 ADB 以查看是否出现任何错误,但除了
03-01 17:44:19.813: E/InputDispatcher(898): channel '437f0100 org.renpy.android.PythonActivity (s)' ~ Channel is unrecoverably broken and will be disposed!
编辑
sdpath = Environment.get_running_app().getExternalStorageDirectory()
行似乎是导致崩溃的原因
你应该尝试这样的事情:
from kivy.app import platform
...
if platform() == 'android':
DATA_FOLDER = os.getenv('EXTERNAL_STORAGE')
还将此包含在您的 buildozer 规范中:
requirements = kivy, pyjnius
实际上我检查了 adb logcat 并观察到 Environment.get_running_app().getExternalStorageDirectory()
提高了
AttributeError: type object 'android.os.Environment' has no attribute 'get_running_app'
使用
sdpath = Environment.getExternalStorageDirectory().getAbsolutePath()
相反。
将这些代码行添加到我的 kivy 应用程序后,当我在我的 android 4.4.4 上启动它时,该应用程序立即崩溃
from jnius import autoclass
try:
Environment = autoclass('android.os.Environment')
sdpath = Environment.get_running_app().getExternalStorageDirectory()
# Not on Android
except:
sdpath = App.get_running_app().user_data_dir
我检查了 ADB 以查看是否出现任何错误,但除了
03-01 17:44:19.813: E/InputDispatcher(898): channel '437f0100 org.renpy.android.PythonActivity (s)' ~ Channel is unrecoverably broken and will be disposed!
编辑
sdpath = Environment.get_running_app().getExternalStorageDirectory()
行似乎是导致崩溃的原因
你应该尝试这样的事情:
from kivy.app import platform
...
if platform() == 'android':
DATA_FOLDER = os.getenv('EXTERNAL_STORAGE')
还将此包含在您的 buildozer 规范中:
requirements = kivy, pyjnius
实际上我检查了 adb logcat 并观察到 Environment.get_running_app().getExternalStorageDirectory()
提高了
AttributeError: type object 'android.os.Environment' has no attribute 'get_running_app'
使用
sdpath = Environment.getExternalStorageDirectory().getAbsolutePath()
相反。