英文:
How do I fix a ReferenceError in my KivyMD app?
问题
我创建了一个 KivyMD 应用,并尝试在 Android 设备上运行它。这个应用是一个叫做“COVID Killers”的游戏。它有一个开始界面、游戏界面和游戏结束界面。在开始界面,你可以开始游戏。在游戏界面,有病毒,你需要用肥皂条击中它们。在游戏结束界面,有一个游戏结束的 GIF,你可以点击一个按钮重新开始游戏。在 Android 设备上,当我扔肥皂时,肥皂飞到病毒那里,但是一旦碰到病毒,应用就崩溃了。我在编写应用程序时曾经提问过另一个问题KivyMD MDFlatButton 不可点击 & Kivy ScreenManager 不起作用。但我最终修复了这个应用程序。因此,由于应用在 Android 上崩溃,我查看了 ADB 日志,并看到了以下的回溯信息:
07-25 14:24:01.802 14777 14870 I python : Traceback (most recent call last):
07-25 14:24:01.802 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/app/main.py", line 427, in <module>
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/app.py", line 855, in run
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/base.py", line 504, in runTouchApp
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/core/window/window_sdl2.py", line 747, in mainloop
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/core/window/window_sdl2.py", line 479, in _mainloop
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/base.py", line 348, in idle
07-25 14:24:01.804 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/clock.py", line 598, in tick_draw
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 427, in kivy._clock.CyClockBase._process_events_before_frame
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 467, in kivy._clock.CyClockBase._process_events_before_frame
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 465, in kivy._clock.CyClockBase._process_events_before_frame
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 154, in kivy._clock.ClockEvent.tick
07-25 14:24:01.805 14777 14870 I python : File "kivy/_clock.pyx", line 86, in kivy._clock.ClockEvent.get_callback
07-25 14:24:01.805 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/weakmethod.py", line 56, in is_dead
07-25 14:24:01.805 14777 14870 I python : ReferenceError: weakly-referenced object no longer exists
07-25 14:24:01.805 14777 14870 I python : Python for android ended.
同时还有一个 Java 错误。由于错误信息实在是太长了,这里有一个链接:Java 错误。
有人知道是什么原因导致我的应用崩溃吗?如果有人需要查看我的应用代码,我会提供一个链接。
提前谢谢!
英文:
I created a KivyMD app and tried running it on an Android device. The app is a game called COVID Killers. There's a start screen, game screen, and a game over screen. In the start screen you start the game. In the game screen, there are viruses and you have to hit them with bars of soap. In the game over screen there's a game over GIF and you can click a button to restart the game. On an Android device, when I throw a bar of soap the soap goes up to the virus but as soon as it hits the virus the app crashes. I already posted another question about this app [KivyMD MDFlatButton not clickable & Kivy ScreenManager not working](https://stackoverflow.com/questions/63079352/kivymd-mdflatbutton-not-clickable-kivy-screenmanager-not-working 'python - KivyMD MDFlatButton not clickable & Kivy ScreenManager not working') when I was still coding it. But I fixed the app eventually. So since the app crashes on Android, I looked at the ADB log, and saw this traceback:
07-25 14:24:01.802 14777 14870 I python : Traceback (most recent call last):
07-25 14:24:01.802 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/app/main.py", line 427, in <module>
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/app.py", line 855, in run
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/base.py", line 504, in runTouchApp
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/core/window/window_sdl2.py", line 747, in mainloop
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/core/window/window_sdl2.py", line 479, in _mainloop
07-25 14:24:01.803 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/base.py", line 348, in idle
07-25 14:24:01.804 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/clock.py", line 598, in tick_draw
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 427, in kivy._clock.CyClockBase._process_events_before_frame
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 467, in kivy._clock.CyClockBase._process_events_before_frame
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 465, in kivy._clock.CyClockBase._process_events_before_frame
07-25 14:24:01.804 14777 14870 I python : File "kivy/_clock.pyx", line 154, in kivy._clock.ClockEvent.tick
07-25 14:24:01.805 14777 14870 I python : File "kivy/_clock.pyx", line 86, in kivy._clock.ClockEvent.get_callback
07-25 14:24:01.805 14777 14870 I python : File "~/MEGAsync/KivyLab/KivyMD/COVIDKillers/.buildozer/android/platform/build-arm64-v8a/build/python-installs/COVIDKillers/kivy/weakmethod.py", line 56, in is_dead
07-25 14:24:01.805 14777 14870 I python : ReferenceError: weakly-referenced object no longer exists
07-25 14:24:01.805 14777 14870 I python : Python for android ended.
There was also a Java error. Since the error is really long, here is a link to it: [Java Error](https://docs.google.com/document/d/14abjob6NQ5pibuAPpOd4gpOs4lMexf88PTMW5uEul8Q/edit?usp=sharing 'Java Error - Google Docs')
Does anybody know what's causing my app to crash? If anyone needs to view the code of my app, I will leave a link to it.
Thanks in advance!
答案1
得分: 0
事实证明,我的应用程序中的一个元素依赖于我后来在程序中删除的一个变量。我已经修复了我的应用程序。
英文:
It turns out one of the elements in my app was dependent on a variable that I deleted later in my program. I've fixed my app now.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论