• <tfoot id='2Jg2M'></tfoot>

    • <bdo id='2Jg2M'></bdo><ul id='2Jg2M'></ul>

      1. <i id='2Jg2M'><tr id='2Jg2M'><dt id='2Jg2M'><q id='2Jg2M'><span id='2Jg2M'><b id='2Jg2M'><form id='2Jg2M'><ins id='2Jg2M'></ins><ul id='2Jg2M'></ul><sub id='2Jg2M'></sub></form><legend id='2Jg2M'></legend><bdo id='2Jg2M'><pre id='2Jg2M'><center id='2Jg2M'></center></pre></bdo></b><th id='2Jg2M'></th></span></q></dt></tr></i><div id='2Jg2M'><tfoot id='2Jg2M'></tfoot><dl id='2Jg2M'><fieldset id='2Jg2M'></fieldset></dl></div>

        <small id='2Jg2M'></small><noframes id='2Jg2M'>

        <legend id='2Jg2M'><style id='2Jg2M'><dir id='2Jg2M'><q id='2Jg2M'></q></dir></style></legend>
      2. Kivy 应用程序无法在 Android 上运行

        时间:2023-09-01

          <small id='EApSE'></small><noframes id='EApSE'>

          • <i id='EApSE'><tr id='EApSE'><dt id='EApSE'><q id='EApSE'><span id='EApSE'><b id='EApSE'><form id='EApSE'><ins id='EApSE'></ins><ul id='EApSE'></ul><sub id='EApSE'></sub></form><legend id='EApSE'></legend><bdo id='EApSE'><pre id='EApSE'><center id='EApSE'></center></pre></bdo></b><th id='EApSE'></th></span></q></dt></tr></i><div id='EApSE'><tfoot id='EApSE'></tfoot><dl id='EApSE'><fieldset id='EApSE'></fieldset></dl></div>

              <legend id='EApSE'><style id='EApSE'><dir id='EApSE'><q id='EApSE'></q></dir></style></legend><tfoot id='EApSE'></tfoot>

              • <bdo id='EApSE'></bdo><ul id='EApSE'></ul>
                  <tbody id='EApSE'></tbody>

                • 本文介绍了Kivy 应用程序无法在 Android 上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想使用 kivy 在 Python 中为 Android 编写简单的应用程序.可悲的是,当我开始示例代码时,我只看到闪屏,几秒钟后应用程序完成工作.调试存在很大问题,因为 Linux Mint 上的 adb 没有检测到我的设备.

                  I want write simple application in Python for Android using kivy. Sadly when I start example code I see only splash screen and few second later application finish work. There is a huge problem with debugging because adb on Linux Mint does not detect my device.

                  谁能看看我的代码并告诉我为什么?要构建应用程序,我使用 buildozer.您还可以查看 create_env 脚本来检查所有依赖项.

                  Can someone look at my code and tell my why? To build application I use buildozer. You can also see create_env script to check all dependencies are there.

                  最好的问候.德拉昆

                  我开始调试我的应用程序.结论:

                  I started debugging my application. Conclusion:

                  • buildozer + python3 + kivy 是个坏主意
                  • 如果我在 text 属性为 str 时使用 kivy.uix.button.Button 则出现异常AttributeError: 'str' object has no attribute 'decode'"
                  • 如果我在 text 属性为字节时使用 kivy.uix.button.Button,则会出现异常ValueError: Button.text accept only str"

                  看起来像没有解决方案的循环.想知道我什么时候应该报告?

                  It looks like loop with no solution. Some idea when I should report it?

                  异常位于 .buildozer/android/platform/build/build/python-installs/pad/android/init.py" 文件中,因此它看起来不像 kivy 和/或 buildozer 异常.

                  Exception is in .buildozer/android/platform/build/build/python-installs/pad/android/init.py" file so it does not look like kivy and/or buildozer exception.

                  推荐答案

                  我用过python-for android工具,遇到了同样的错误.但在我的情况下,应用程序根本没有运行 - 从启动屏幕崩溃.最后,我找到了解决方案.你可以试试同样的方法.

                  I've used python-for android tool and faced with the same errors. But in my case, app didn't run at all - crashed from splash screen. Finally, I've found a solution. You can try the same way.

                  所以我的管道是 python3 + python-for-android(p4a 工具,python-for-android,来自 master 分支)+ kivy (1.10.1)

                  So my pipeline was python3 + python-for-android (p4a tool, python-for-android, from master branch) + kivy (1.10.1)

                  有一个文件_android.pyx"用于 android 构建配方(您可以通过命令 p4a recipes 查看可用的 p4a 配方的完整列表).该文件可能由 Buildozer 使用,并且在 APK 构建过程中完全由 P4A 使用.你需要修复它.

                  There is a file "_android.pyx" for android building recipe (full list of avaliable p4a recipes you can see by command p4a recipes). This file is, possibly, used by Buildozer, and exactly used by P4A during APK building procedure. You need to fix it.

                  您可以通过以下方式在 Ubuntu 中找到它的位置(例如):

                  You may find it's location in Ubuntu (for example) via:

                  sudo updatedb
                  locate _android.pyx
                  

                  它的路径应该是这样的:

                  It's path should be something like:

                  ~/.local/lib/python3.6/site-packages/pythonforandroid/recipes/android/src/android/_android.pyx
                  

                  应该有一个字符串:

                  python_act = autoclass(JAVA_NAMESPACE.decode('utf-8') + u'.PythonActivity')
                  

                  所以你应该改变它 - 像这样:

                  so you should change it - something like this:

                  python_act = autoclass(str(JAVA_NAMESPACE) + u'.PythonActivity'),
                  

                  或者只是使用一些硬代码:

                  or just use some hardcode:

                  python_act = autoclass("org/kivy/android/PythonActivity")
                  

                  或者来源中可能有其他 decode() 用法.

                  Or there might be the other decode() usage in sources.

                  原因:Python2 和 Python3 之间的差异 - decode() 方法可用于 Python 2 或 3 中的等效二进制数据类型,但它不能被 Python 2 和 3 之间的文本数据类型一致地使用因为 Python 3 中的 str 没有方法 decode 函数在 Python3 中有不同的实现.更多细节在这里:pyporting 功能问题p4a的github

                  The reason: differences between Python2 and Python3 - the decode() method is usable on the equivalent binary data type in either Python 2 or 3, but it can’t be used by the textual data type consistently between Python 2 and 3 because str in Python 3 doesn’t have the method decode function has different realisation in Python3. More details are here: pyporting features issues p4a's github

                  希望对你有所帮助.

                  这篇关于Kivy 应用程序无法在 Android 上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 buildozer 打包 apk 时出现 mpmath 和 sympy 错误 下一篇:armeabi-v7a、arm64-v8a、x86 有什么区别?

                  相关文章

                  最新文章

                  <small id='p7DWh'></small><noframes id='p7DWh'>

                  <i id='p7DWh'><tr id='p7DWh'><dt id='p7DWh'><q id='p7DWh'><span id='p7DWh'><b id='p7DWh'><form id='p7DWh'><ins id='p7DWh'></ins><ul id='p7DWh'></ul><sub id='p7DWh'></sub></form><legend id='p7DWh'></legend><bdo id='p7DWh'><pre id='p7DWh'><center id='p7DWh'></center></pre></bdo></b><th id='p7DWh'></th></span></q></dt></tr></i><div id='p7DWh'><tfoot id='p7DWh'></tfoot><dl id='p7DWh'><fieldset id='p7DWh'></fieldset></dl></div>

                    • <bdo id='p7DWh'></bdo><ul id='p7DWh'></ul>
                    <tfoot id='p7DWh'></tfoot>

                      <legend id='p7DWh'><style id='p7DWh'><dir id='p7DWh'><q id='p7DWh'></q></dir></style></legend>