当 Kivy 应用程序在 Android 上停止时,logcat 输出无信息
Posted
技术标签:
【中文标题】当 Kivy 应用程序在 Android 上停止时,logcat 输出无信息【英文标题】:The logcat output uninformative when Kivy app stops on Android 【发布时间】:2020-01-04 08:28:24 【问题描述】:我在 Ubuntu 上使用 kivy v1.10.1、buildozer 0.39 和 python 3.5.2。
我有一个非常基本的 kivy 应用程序
from kivy.app import App
from kivy.uix.screenmanager import Screen
from kivy.uix.button import Label
from kivy.lang import Builder
root = Builder.load_string('''
<MainFrame>:
Label:
text: 'Hello world'
''')
class MainFrame(Screen):
def __init__(self, **kwargs):
super(MainFrame, self).__init__(**kwargs)
class BasicApp(App):
def build(self):
return MainFrame()
if __name__ == '__main__':
BasicApp().run()
buildozer 规范包括:
requirements = python3, kivy
我可以使用 buildozer 构建 APK,但是当我在 android 设备上运行它时,它似乎会加载,但随后会停止。
这似乎是 logcat 输出的相关部分
-31 12:18:56.281 7803 7803 D InputTransport: Input channel destroyed: fd=53
08-31 12:18:56.282 3620 4975 I WindowManager: WIN DEATH: Windowe85acd2d0 u0 org.test.myapp/org.kivy.android.PythonActivity
08-31 12:18:56.282 3620 4975 D WindowManager: disposeInputChannel mInputChannel: e85acd2 org.test.myapp/org.kivy.android.PythonActivity (server)
08-31 12:18:56.282 3620 4975 W InputDispatcher: Attempted to unregister already unregistered input channel
08-31 12:18:56.283 30622 30622 D [WeatherWidget(15503)] DB L2: [610591C4E30FED4A153FF198DAC84EFEE3319B0D622FD4A19809E90ED3C1398368D658B139FCCB8B9564F5B4E9CB634EAEB5D3DD5DDD4E73700B72505132108E]
08-31 12:18:56.284 30622 30622 D [WeatherWidget(15503)] : [E9BDC1AC9F9B078A92B3F309630276C89F9B6E52C087A495B97355481F2FDE5B58A757A09967AB7BD9E1187CEA5BB356FACBD4A552A7402C88647F970C513A69]
08-31 12:18:56.284 3620 7254 I ActivityManager: Process org.test.myapp (pid 30399) has died(75,351)
08-31 12:18:56.285 3620 7254 D ActivityManager: cleanUpApplicationRecord -- 30399
08-31 12:18:56.285 3620 4975 D InputDispatcher: Focus left window: 30399
08-31 12:18:56.285 3620 4975 D InputTransport: Input channel destroyed: fd=549
08-31 12:18:56.286 3620 7254 W ActivityManager: Force removing ActivityRecord74325c3d0 u0 org.test.myapp/org.kivy.android.PythonActivity t14282: app died, no saved state
08-31 12:18:56.286 3620 4975 D InputTransport: Input channel constructed: fd=549
08-31 12:18:56.286 3620 4975 D InputTransport: Input channel constructed: fd=624
08-31 12:18:56.286 30642 30666 I DatabaseManager: [#CMH#] createTables
08-31 12:18:56.286 3620 4975 D WindowManager: openInputChannel mInputChannel: e85acd2 org.test.myapp/org.kivy.android.PythonActivity (server)
08-31 12:18:56.287 3620 4975 D InputDispatcher: Focus entered window: 30399
08-31 12:18:56.287 3620 5346 I WindowManager: WIN DEATH: Windowd2e042ad0 u0 SurfaceView - org.test.myapp/org.kivy.android.PythonActivity
08-31 12:18:56.290 3620 7254 W MultiScreenManagerService: moveTaskBackToDisplayIfNeeded(): root is not base activity
08-31 12:18:56.294 30642 30666 I CloudEventSyncTable: [#CMH#] CloudEventSyncTable constructor
08-31 12:18:56.295 30642 30666 I EventSyncCacheTable: [#CMH#] EventSyncBackUpTable constructor
08-31 12:18:56.295 30642 30666 I DatabaseManager: [#CMH#] DB init done ReadOnly: false
08-31 12:18:56.295 30642 30666 I Controller: [#CMH#] ServicesSetValue = 41881406
08-31 12:18:56.297 3620 7254 D GameManagerService: there is not sem_perfomance_mode on setting
08-31 12:18:56.301 30642 30666 I Controller: [#CMH#] storagepermisssion = 0
08-31 12:18:56.301 30642 30666 I Controller: [#CMH#] initializeBroadcastReceiver com.samsung.cmh.database.DatabaseManager@8c4b3c8
08-31 12:18:56.302 30642 30666 I SystemBroadcastReceiver: [#CMH#] in initialize
08-31 12:18:56.302 30642 30666 I SystemBroadcastReceiver: [#CMH#] SystemBroadcastReceiver
08-31 12:18:56.307 3620 5346 I WindowManager_SurfaceController: Destroying surface Surface(name=SurfaceView - org.test.myapp/org.kivy.android.PythonActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2906 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:1120 com.android.server.wm.WindowState.removeLocked:1880 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2924 com.android.server.wm.WindowManagerService.removeWindowLocked:2864 com.android.server.wm.WindowState$DeathRecipient.binderDied:2320 android.os.BinderProxy.sendDeathNotice:701 <bottom of call stack>
08-31 12:18:56.308 3072 7256 I SurfaceFlinger: id=1073 Removed QythonActiv (4/12)
08-31 12:18:56.308 3072 3134 I SurfaceFlinger: id=1074 Removed QythonActiv (3/11)
08-31 12:18:56.308 3072 3134 I SurfaceFlinger: id=1073 Removed QythonActiv (-2/11)
08-31 12:18:56.308 3072 3134 I SurfaceFlinger: id=1074 Removed QythonActiv (-2/11)
08-31 12:18:56.326 3620 7254 D InputDispatcher: Focus left window: 30399
08-31 12:18:56.327 3620 7254 D WindowManager: disposeInputChannel mInputChannel: e85acd2 org.test.myapp/org.kivy.android.PythonActivity (server)
08-31 12:18:56.327 3620 7254 D InputTransport: Input channel destroyed: fd=624
08-31 12:18:56.346 3620 7254 I WindowManager_SurfaceController: Destroying surface Surface(name=org.test.myapp/org.kivy.android.PythonActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2906
完整的 logcat 文本位于:
https://justpaste.it/7hge7
谁能指出问题的可能根源?
【问题讨论】:
发布应用程序启动和崩溃之间的完整 lgocat 输出。您也可以只删除包含字符串python
的行来缩小搜索范围。
@inclement 我已将 logcat 输出粘贴到 justpaste.it/7hge7
不幸的是,我没有看到任何明显的错误 - 加载 libpython2.7.so 时似乎存在问题,但这甚至不应该发生。您可以粘贴完整的 logcat 而不限制包含 python
的行吗?这可能是一个较低级别的问题,我们必须关心 Python 进程本身以外的其他内容。
@inclement 这里是完整的 logcat ge.tt/2CRlJrx2
奇怪的是它正在尝试加载 libpython2.7。你能发布你的buildozer.spec
文件吗?
【参考方案1】:
logcat中实际的traceback是这部分:
08-31 14:29:28.636 29017 29035 I python : Traceback (most recent call last):
08-31 14:29:28.636 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/app/main.py", line 21, in <module>
08-31 14:29:28.637 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/app.py", line 829, in run
08-31 14:29:28.637 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/app/main.py", line 18, in build
08-31 14:29:28.638 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/app/main.py", line 14, in __init__
08-31 14:29:28.638 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/relativelayout.py", line 265, in __init__
08-31 14:29:28.639 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/floatlayout.py", line 65, in __init__
08-31 14:29:28.639 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/layout.py", line 76, in __init__
08-31 14:29:28.639 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/widget.py", line 361, in __init__
08-31 14:29:28.640 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/uix/widget.py", line 469, in apply_class_lang_rules
08-31 14:29:28.640 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/lang/builder.py", line 538, in apply
08-31 14:29:28.641 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/lang/builder.py", line 654, in _apply_rule
08-31 14:29:28.641 29017 29035 I python : File "kivy/_event.pyx", line 188, in kivy._event.EventDispatcher.__cinit__
08-31 14:29:28.641 29017 29035 I python : File "kivy/properties.pyx", line 447, in kivy.properties.Property.link
08-31 14:29:28.642 29017 29035 I python : File "kivy/properties.pyx", line 632, in kivy.properties.NumericProperty.init_storage
08-31 14:29:28.642 29017 29035 I python : File "kivy/properties.pyx", line 418, in kivy.properties.Property.init_storage
08-31 14:29:28.642 29017 29035 I python : File "kivy/properties.pyx", line 655, in kivy.properties.NumericProperty.convert
08-31 14:29:28.643 29017 29035 I python : File "kivy/properties.pyx", line 663, in kivy.properties.NumericProperty.parse_str
08-31 14:29:28.643 29017 29035 I python : File "kivy/properties.pyx", line 670, in kivy.properties.NumericProperty.parse_list
08-31 14:29:28.643 29017 29035 I python : File "kivy/properties.pyx", line 296, in kivy.properties.dpi2px
08-31 14:29:28.644 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/utils.py", line 505, in __get__
08-31 14:29:28.645 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/kivy/metrics.py", line 162, in dpi
08-31 14:29:28.645 29017 29035 I python : File "/home/jeff/projects/basic_kivy_app/.buildozer/android/platform/build/build/python-installs/myapp/jnius/__init__.py", line 12, in <module>
08-31 14:29:28.646 29017 29035 I python : ImportError: dlopen failed: library "libpython2.7.so" not found
08-31 14:29:28.646 29017 29035 I python : Python for android ended.
我不知道是什么原因造成的。看起来 pyjnius 与 python2.7 相关联,但我不明白为什么会出现这种情况(p4a 应该特别注意它不会发生)。这是您尝试的第一个构建吗?如果您清理所有内容并再次运行,是否会发生同样的情况?
【讨论】:
是的。那解决了它。我删除了 .buildozer 文件夹,没关系。我想肯定有一些垃圾漂浮在周围【参考方案2】:问题已通过删除 .buildozer 文件夹并重新开始解决。
我想我之前有过这样的台词:
requirements = python2, kivy
在 buildozer.spec 中,当我遇到问题时,我将其更改为:
requirements = python3, kivy
但没有删除 .buildozer 文件夹。
这可能导致了问题中涉及的问题。
我提供此答案是为了鼓励可能遇到类似问题的其他人删除 .buildozer 文件夹并在寻求帮助之前从干净的构建开始。我之前应该想到的。
【讨论】:
以上是关于当 Kivy 应用程序在 Android 上停止时,logcat 输出无信息的主要内容,如果未能解决你的问题,请参考以下文章
Python/Kivy/Buildozer - 应用程序在 Android 中崩溃,但在 PC 上运行良好
例外:SDL2:无法加载图像 - 在 android 上运行 kivy apk 时