【问题标题】:I have problems opening my app on Android after using Kivy/Buildozer使用 Kivy/Buildozer 后在 Android 上打开我的应用程序时遇到问题
【发布时间】:2019-08-11 14:16:26
【问题描述】:

我正在开发一个最终将使用 OpenCV 的 android 应用程序项目(还没有达到那个部分)。我只完成了项目的功能部分,但它在我的 Android 手机 (Haewai P20) 上打开后就一直崩溃。在此之前,我进行了著名的“Hello world”测试,显示这两个词的应用程序打开良好。我阅读了很多论坛,但找不到任何解决方案。

我正在使用 python 3.7 开发 PyCharm,当我在 Windows 上打开它时,该应用程序运行良好。然后我在 VirtualBox 6.0.6 上的 Ubuntu 18.04 上使用 buildozer。

我不想复制粘贴我所有的 logcat、buildozer.spec 和日志文件,所以你可以在这里查看它们:

buildozer.spec:

https://drive.google.com/open?id=1DHClpIxnOGKtev2nRefau85v12IzjJWm

使用 buildozer 创建的 log.txt:

https://drive.google.com/open?id=1wlQmQjWH27WRef--tLPtN9FGWTE13lLL

logcat.txt(只有我安装并打开的部分):

https://drive.google.com/open?id=17ovrucpeKWpJh6MBw7e5ZUbxO3S1DSnS

我不确定要看什么。我感觉 Python 版本之间存在不兼容性(buildozer 使用 2.7),但我不确定如何处理。如果真的是问题。

如果您在打开这些文件时遇到问题以及需要其他任何东西,请告诉我。

非常感谢您的帮助和时间。

【问题讨论】:

    标签: python android kivy buildozer


    【解决方案1】:

    如何在logcat中查找错误?

    使用编辑器搜索“I python”或buildozer android debug deploy run > grep "I python"

    Logcat3.txt - 错误

    08-11 17:05:10.323  7746  7801 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/org.test.digitable/files/app/.kivy/logs/kivy_19-08-11_0.txt
    08-11 17:05:10.323  7746  7801 I python  : [INFO   ] [Kivy        ] v1.11.0
    08-11 17:05:10.323  7746  7801 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/org.test.digitable/files/app/_python_bundle/site-packages/kivy/__init__.pyo"
    08-11 17:05:10.323  7746  7801 I python  : [INFO   ] [Python      ] v2.7.15 (default, Aug 11 2019, 16:47:41)
    08-11 17:05:10.323  7746  7801 I python  : [GCC 4.2.1 Compatible Android (4691093 based on r316199) Clang 6.0.2 (https://a
    08-11 17:05:10.323  7746  7801 I python  : [INFO   ] [Python      ] Interpreter at ""
    08-11 17:05:10.324  7746  7801 I python  : [WARNING] [Deprecated  ] Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore
    08-11 17:05:10.781  7746  7801 I python  : [INFO   ] [Factory     ] 184 symbols loaded
    08-11 17:05:11.027  7746  7801 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
    08-11 17:05:11.063  7746  7801 I python  : [INFO   ] [Window      ] Provider: sdl2
    08-11 17:05:11.217  7746  7801 I python  : [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
    08-11 17:05:11.218  7746  7801 I python  : [INFO   ] [GL          ] Backend used <sdl2>
    08-11 17:05:11.219  7746  7801 I python  : [INFO   ] [GL          ] OpenGL version <OpenGL ES 3.2 v1.r14p0-00cet0.0416641283c5d6e2d53c163d0ca99357>
    08-11 17:05:11.219  7746  7801 I python  : [INFO   ] [GL          ] OpenGL vendor <ARM>
    08-11 17:05:11.219  7746  7801 I python  : [INFO   ] [GL          ] OpenGL renderer <Mali-G72>
    08-11 17:05:11.219  7746  7801 I python  : [INFO   ] [GL          ] OpenGL parsed version: 3, 2
    08-11 17:05:11.220  7746  7801 I python  : [INFO   ] [GL          ] Texture max size <8192>
    08-11 17:05:11.220  7746  7801 I python  : [INFO   ] [GL          ] Texture max units <16>
    08-11 17:05:11.268  7746  7801 I python  : [INFO   ] [Window      ] auto add sdl2 input provider
    08-11 17:05:11.269  7746  7801 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
    08-11 17:05:11.272  7746  7801 I python  :  Traceback (most recent call last):
    08-11 17:05:11.272  7746  7801 I python  :    File "/home/laurent/Downloads/Files4apk/.buildozer/android/app/main.py", line 15, in <module>
    08-11 17:05:11.273  7746  7801 I python  :    File "/home/laurent/Downloads/Files4apk/.buildozer/android/platform/build/build/python-installs/digitable/pandas/__init__.py", line 19, in <module>
    08-11 17:05:11.273  7746  7801 I python  :  ImportError: Missing required dependencies ['numpy', 'pytz', 'dateutil']
    08-11 17:05:11.273  7746  7801 I python  : Python for android ended.
    

    问题

    您的 buildozer.spec 缺少依赖项 ['numpy', 'pytz', 'dateutil']

    解决方案

    将依赖项 ['numpy', 'pytz', 'dateutil'] 添加到 buildozer.spec 中的需求

    requirements = python2,kivy,pandas,numpy,pytz,dateutil
    

    Logcat1.txt - 错误

    08-11 09:19:50.492 10715 10755 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/org.test.digitable/files/app/.kivy/logs/kivy_19-08-11_1.txt 
    08-11 09:19:50.492 10715 10755 I python  : [INFO   ] [Kivy        ] v1.11.0 
    08-11 09:19:50.493 10715 10755 I python  : [INFO   ] [Kivy     ] Installed at "/data/user/0/org.test.digitable/files/app/_python_bundle/site-packages/kivy/__init__.pyo" 
    08-11 09:19:50.493 10715 10755 I python  : [INFO   ] [Python      ] v2.7.15 (default, Aug 10 2019, 22:32:55)  
    08-11 09:19:50.493 10715 10755 I python  : [GCC 4.2.1 Compatible Android (4691093 based on r316199) Clang 6.0.2 (https://a 
    08-11 09:19:50.493 10715 10755 I python  : [INFO   ] [Python      ] Interpreter at "" 
    08-11 09:19:50.494 10715 10755 I python  : [WARNING] [Deprecated  ] Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore 
    08-11 09:19:50.495 10715 10755 I python  :  Traceback (most recent call last): 
    08-11 09:19:50.495 10715 10755 I python  :    File "/home/laurent/Downloads/Files4apk/.buildozer/android/app/main.py", line 2, in <module> 
    08-11 09:19:50.495 10715 10755 I python  :    File "/home/laurent/Downloads/Files4apk/.buildozer/android/platform/build/build/python-installs/digitable/kivy/__init__.py", line 139, in require 
    08-11 09:19:50.496 10715 10755 I python  :  Exception: The version of Kivy installed on this system is too old. (You have 1.11.0, but the application requires 1.11.1) 
    08-11 09:19:50.496 10715 10755 I python  : Python for android ended.
    

    问题

    1. 在您的 buildozer.spec 中,您指定了 Kivy 版本 1.11.1 和 Python 2,但在您的 Kivy 应用,(main.py),它有 1.11.0
    2. Python 2 Kivy 支持已被弃用。 1.11.0 之后的 Kivy 版本将不再支持 Python 2

    解决方案

    1. 要么删除 main.py 中的以下内容,要么将其更改为 '1.11.1'(即与 buildozer.spec 相同)
        import kivy
        kivy.require('1.11.0')
    
    1. 如果你想使用 Kivy 版本 1.11.1,你必须将 python2 替换为 python3requirements

    【讨论】:

    • 感谢您帮助我纠正这个愚蠢的错误。 buildozer.spec 中的“osx.python_version”怎么样。应该是2还是3?所以我将所有内容都更改为 1.11.0 并将 python2 放入要求中,我没有这个错误。但是还是打不开。它崩溃了,但没有以前那么快了。如果您可以查看 log.txt 和 logcat,那就太棒了。谢谢你。 drive.google.com/open?id=1dUIT0sFDofREzGG4l8lBLhK8VN4I5W8tdrive.google.com/open?id=14f7XrudPKXNY0Ls_2UOelQE_brna-f7M
    • @Laurent 您是否自己查看了 logcat 以试图找到问题?您了解 ikolim 是如何发现第一个问题的吗?
    • 在这个新的 logcat 中,我根本看不到您的应用正在运行。
    • @Laurent:由于缺少依赖项 ['numpy'、'pytz'、'dateutil'],重新运行 Kivy 应用程序失败。解决方案:将依赖项 ['numpy', 'pytz', 'dateutil'] 添加到 buildozer.spec 中的需求,requirements = python2,kivy,pandas,numpy,pytz,dateutil。详情请查看更新后的帖子。
    • 您的应用因TypeError: add_docstring() argument 2 must be str, not None 而崩溃。不要太担心警告消息,因为它不会导致您的应用程序崩溃。如果您真的想摆脱警告,请将python2 替换为python3requirements,并在您的buildozer.spec 中将osx.kivy_version = 1.0.6 替换为osx.kivy_version = 1.11.1。但在此之前,请确保您的 Kivy 应用程序与 Python 3 兼容/准备就绪。
    猜你喜欢
    • 2023-03-27
    • 2020-11-02
    • 2021-09-11
    • 2020-09-07
    • 2022-10-21
    • 2022-08-24
    • 2021-09-23
    • 1970-01-01
    • 2014-04-15
    相关资源
    最近更新 更多