Kivy-Ubuntu 在“buildozer android logcat”之后崩溃

Posted

技术标签:

【中文标题】Kivy-Ubuntu 在“buildozer android logcat”之后崩溃【英文标题】:Kivy-Ubuntu crashes after "buildozer android logcat" 【发布时间】:2018-08-25 12:11:00 【问题描述】:

今天的最后一次编辑:

为“buildozer android logcat”和“buildozer android debug deploy run logcat”的日志文件创建了github repo。

删除了我的答案,我在其中发布了此日志文件的一小部分。

编辑 18.03.2018:

我又回到了我开始这个线程的问题:我可以通过 Kivy Launcher 启动我的应用程序,我可以从我的源代码构建一个 apk 文件,我可以安装这个 apk 文件。但我无法调试此 apk 文件(请参阅下面的原始消息)。

我发现您可以使用“script -a history_for_***.txt”记录终端历史记录(命令 + 输出)。然而,“buildozer android logcat”进程运行时不到一分钟就会产生超过 600000(六十万)个字符的日志记录。显然 *** 问题最多有 30000 个字符。

我将发布日志文件的第一部分作为我自己问题的答案。但正如我在原始消息中提到的,对我来说,输出似乎是高度重复的,并且与我的应用程序无关。我的应用程序的启动和崩溃(在 logcat 过程中)似乎对终端窗口中的输出没有任何影响。而且我不能排除测试部分(我的应用程序在哪里启动/在哪里崩溃)是我可以在此处发布的日志的一部分。

如果我可以给您写一封包含完整日志文件的电子邮件,请告诉我。欢迎任何其他建议!

================================================ ============================

编辑 18.03.2018:

好的,我尝试了更多的东西:我可以从 kivy 示例“touchtracer”应用程序构建一个 apk 文件。 “buildozer andoid debug”期间没有错误。所以 buildozer-vm 似乎没问题。由于构建过程适用于示例应用程序,因此很明显问题不是 buildozer-vm,而是我的应用程序/代码。

touchtracer 应用依赖于数学和随机模块。因此,在第二次尝试中,我将这些库包含在需求行的 buildozer.spec 文件中。细化会破坏构建过程。所以我想不必在 buildozer.spec 文件中指定标准库。这可能是我的构建过程不再工作的第一个原因(我确实在我的 CalculationGame 的 buildozer.spec 文件中指定了操作员、网络浏览器、随机数等)。

同时我在手机文件系统中找到了 Kivy-Launcher 的日志文件:“kivy/CalculationGame/.kivy/logs/*.txt”。他们建议我的应用程序由于错误的 super().init 语句而崩溃。我使用 python 3 表示法,您不必将子类指定为 super() 调用的参数。但是,在 python 2 中,您需要这样做。

我必须切换到 python 2 表示法吗?也许 buildozer.spec 文件中有一些行,我可以在其中定义 kivy 应该期望 python 3 代码?

为了完整起见,我发布了“Kivy Launcher”启动我的CalculationGame的日志文件:

[INFO              ] Logger: Record log in /storage/emulated/0/kivy/CalculationGame/.kivy/logs/kivy_18-03-16_5.txt
[INFO              ] Kivy: v1.9.1
[INFO              ] Python: v2.7.2 (default, Mar 20 2016, 23:30:13) 
[GCC 4.8]
[INFO              ] Factory: 179 symbols loaded
[WARNING           ] stderr: /data/data/org.kivy.pygame/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:13: RuntimeWarning: import cdrom: No module named cdrom
[WARNING           ] stderr: (ImportError: No module named cdrom)
[INFO              ] Image: Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
[INFO              ] Window: Provider: pygame
[INFO              ] GL: OpenGL version <OpenGL ES 3.0 V@84.0 AU@05.00.02.006.020 (CL@)>
[INFO              ] GL: OpenGL vendor <Qualcomm>
[INFO              ] GL: OpenGL renderer <Adreno (TM) 320>
[INFO              ] GL: OpenGL parsed version: 3, 0
[INFO              ] GL: Texture max size <4096>
[INFO              ] GL: Texture max units <16>
[INFO              ] Shader: program: <--From Vertex Shader:
--From Fragment Shader:
Link was successful.>
[INFO              ] Support: Android install hooks
[INFO              ] Window: virtual keyboard not allowed, single mode, not docked
[INFO              ] Text: Provider: pygame
[WARNING           ] stderr: Traceback (most recent call last):
[WARNING           ] stderr:   File "main.py", line 497, in <module>
[WARNING           ] stderr:     CalculationApp().run()
[WARNING           ] stderr:   File "main.py", line 387, in __init__
[WARNING           ] stderr:     super().__init__(*args, **kwargs)
[WARNING           ] stderr: TypeError: super() takes at least 1 argument (0 given)

================================================ ==========================

编辑 18.03.2018:

我在我的应用程序中使用了一些标准的 Python 库(运算符、日期时间、functools 等),但我没有在我的 buildozer.spec 文件中指定它们。我认为这可能是该应用程序立即在我的手机上崩溃的原因。

但是,既然我已经在 buildozer.spec 文件中指定了库,那么构建过程“buildozer android debug”就会出错:

kivy@kivyvm:~$ cd Projects
kivy@kivyvm:~/Projects$ cd CalcGame
kivy@kivyvm:~/Projects/CalcGame$ ls
bin             CalcGameStats.txt  calculation.kv    main.py  Pipfile.lock
buildozer.spec  calculation.ini    json_settings.py  Pipfile  __pycache__
kivy@kivyvm:~/Projects/CalcGame$ buildozer android debug
# Check configu

ration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.18.10 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /usr/local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool
# Install platform
# Run 'pip install -q --user "appdirs" "colorama>=0.3.3" "sh>=1.10,<1.12.5" "jinja2" "six"'
# Cwd None
# Apache ANT found at /home/kivy/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/kivy/.buildozer/android/platform/android-sdk-20
# Android NDK found at /home/kivy/.buildozer/android/platform/android-ndk-r9c
# Check application requirements
# Check garden requirements
# Compile platform
# Run '/usr/bin/python -m pythonforandroid.toolchain create --dist_name=calcgame --bootstrap=sdl2 --requirements=kivy,operator,webbrowser,random,datetime,functools,android --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Projects/CalcGame/.buildozer/android/platform/build'
# Cwd /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI
[INFO]:    Available Android APIs are (19)
[INFO]:    Requested API target 19 is available, continuing.
[INFO]:    Found NDK dir in $ANDROIDNDK
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Using Google NDK r9c
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv
[INFO]:    ccache is missing, the build will not be optimized in the future.
[INFO]:    Found the following toolchain versions: ['4.6', '4.8', 'clang3.3']
[INFO]:    Picking the latest gcc toolchain, here 4.8
[WARNING]: Missing executable: autoconf is not installed
[WARNING]: Missing executable: automake is not installed
[WARNING]: Missing executable: libtoolize is not installed
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.
[INFO]:    Found multiple valid dependency orders:
[INFO]:        [u'datetime', u'functools', 'hostpython2', u'operator', u'random', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', u'webbrowser', 'python2', 'sdl2', 'six', u'android', 'pyjnius', u'kivy']
[INFO]:        [u'datetime', u'functools', 'hostpython3crystax', u'operator', u'random', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', u'webbrowser', 'python3crystax', 'sdl2', 'six', u'android', 'pyjnius', u'kivy']
[INFO]:        [u'datetime', u'functools', 'hostpython2', u'operator', 'pygame_bootstrap_components', u'random', u'webbrowser', 'python2', 'sdl', 'six', 'pygame', 'pyjnius', u'android', u'kivy']
[INFO]:    Using the first of these: [u'datetime', u'functools', 'hostpython2', u'operator', u'random', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', u'webbrowser', 'python2', 'sdl2', 'six', u'android', 'pyjnius', u'kivy']
[INFO]:    The selected bootstrap is sdl2_gradle
[INFO]:    # Creating dist with sdl2_gradle bootstrap
[INFO]:    Dist will have name calcgame and recipes (kivy, operator, webbrowser, random, datetime, functools, android)
[INFO]:    Dist will also contain modules (operator, functools, random, webbrowser, datetime) installed from pip
[INFO]:    -> running cp -r /home/kivy/Projects/Calc...(and 210 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Recipe build order is ['hostpython2', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'python2', 'sdl2', 'six', u'android', 'pyjnius', u'kivy']
[INFO]:    The requirements (datetime, functools, operator, random, webbrowser) were not found as recipes, they will be installed with pip.
[INFO]:    # Downloading recipes 
[INFO]:    Downloading hostpython2
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 62 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/hostpython2
[INFO]:    -> running basename https://python.org/ftp...(and 34 more)
[INFO]:    hostpython2 download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading sdl2_image
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 61 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/sdl2_image
[INFO]:    -> running basename https://www.libsdl.or...(and 52 more)
[INFO]:    sdl2_image download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading sdl2_mixer
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 61 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/sdl2_mixer
[INFO]:    -> running basename https://www.libsdl.or...(and 52 more)
[INFO]:    sdl2_mixer download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading sdl2_ttf
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 59 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/sdl2_ttf
[INFO]:    -> running basename https://www.libsdl.org...(and 48 more)
[INFO]:    sdl2_ttf download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading python2
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 58 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/python2
[INFO]:    -> running basename https://python.org/ftp...(and 34 more)
[INFO]:    python2 download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading sdl2
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 55 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/sdl2
[INFO]:    -> running basename https://www.libsdl.org...(and 26 more)
[INFO]:    sdl2 download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading six
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 54 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/six
[INFO]:    -> running basename https://pypi.python.or...(and 40 more)
     [INFO]:    six download already cached, skipping                          
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading android
[INFO]:    Skipping android download as no URL is set
[INFO]:    Downloading pyjnius
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 58 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/pyjnius
[INFO]:    -> running basename https://github.com/kiv...(and 28 more)
[INFO]:    pyjnius download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Downloading kivy
[INFO]:    -> running mkdir -p /home/kivy/Projects/C...(and 55 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/packages/kivy
[INFO]:    -> running basename https://github.com/kiv...(and 25 more)
[INFO]:    kivy download already cached, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    # Building all recipes for arch armeabi-v7a
[INFO]:    # Unpacking recipes
[INFO]:    Unpacking hostpython2 for armeabi-v7a
[INFO]:    -> running basename https://python.org/ftp...(and 34 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop
[INFO]:    hostpython2 is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking sdl2_image for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.or...(and 52 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni
[INFO]:    sdl2_image is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking sdl2_mixer for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.or...(and 52 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni
[INFO]:    sdl2_mixer is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking sdl2_ttf for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org...(and 48 more)
           work[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni
[INFO]:    sdl2_ttf is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking python2 for armeabi-v7a
[INFO]:    -> running basename https://python.org/ftp...(and 34 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/python2/armeabi-v7a
[INFO]:    python2 is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking sdl2 for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org...(and 26 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni
[INFO]:    sdl2 is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking six for armeabi-v7a
[INFO]:    -> running basename https://pypi.python.or...(and 40 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/six-python2/armeabi-v7a
[INFO]:    six is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    -> running rm -rf /home/kivy/Projects/Cal...(and 99 more)
[INFO]:    -> running cp -a /home/kivy/Projects/Calc...(and 225 more)
[INFO]:    Unpacking pyjnius for armeabi-v7a
[INFO]:    -> running basename https://github.com/kiv...(and 28 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/pyjnius-python2-sdl2/armeabi-v7a
[INFO]:    pyjnius is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Unpacking kivy for armeabi-v7a
[INFO]:    -> running basename https://github.com/kiv...(and 25 more)
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/kivy-python2-sdl2/armeabi-v7a
[INFO]:    kivy is already unpacked, skipping
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    # Prebuilding recipes
[INFO]:    Prebuilding hostpython2 for armeabi-v7a
[INFO]:    -> running cp /home/kivy/Projects/CalcGam...(and 233 more)
[INFO]:    Prebuilding sdl2_image for armeabi-v7a
[INFO]:    sdl2_image has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for sdl2_image[armeabi-v7a]
[INFO]:    sdl2_image already patched, skipping
[INFO]:    Prebuilding sdl2_mixer for armeabi-v7a
[INFO]:    sdl2_mixer has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for sdl2_mixer[armeabi-v7a]
[INFO]:    sdl2_mixer already patched, skipping
[INFO]:    Prebuilding sdl2_ttf for armeabi-v7a
[INFO]:    sdl2_ttf has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding python2 for armeabi-v7a
[INFO]:    python2 has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for python2[armeabi-v7a]
[INFO]:    python2 already patched, skipping
[INFO]:    Prebuilding sdl2 for armeabi-v7a
[INFO]:    sdl2 has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for sdl2[armeabi-v7a]
[INFO]:    sdl2 already patched, skipping
[INFO]:    Prebuilding six for armeabi-v7a
[INFO]:    six has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding android for armeabi-v7a
[INFO]:    android has no prebuild_armeabi_v7a, skipping
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/android-python2-sdl2/armeabi-v7a/android
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Prebuilding pyjnius for armeabi-v7a
[INFO]:    pyjnius has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for pyjnius[armeabi-v7a]
[INFO]:    pyjnius already patched, skipping
[INFO]:    Prebuilding kivy for armeabi-v7a
[INFO]:    kivy has no prebuild_armeabi_v7a, skipping
[INFO]:    # Building recipes
[INFO]:    Building hostpython2 for armeabi-v7a
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2
[INFO]:    hostpython already exists, skipping build
[INFO]:    <- directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Building sdl2_image for armeabi-v7a
[INFO]:    Building sdl2_mixer for armeabi-v7a
[INFO]:    Building sdl2_ttf for armeabi-v7a
[INFO]:    Building python2 for armeabi-v7a
[INFO]:    Copying hostpython binary to targetpython folder
[INFO]:    -> running cp /home/kivy/Projects/CalcGam...(and 207 more)
[INFO]:    Building sdl2 for armeabi-v7a
[INFO]:    -> directory context /home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni
[INFO]:    -> running ndk-build V=1
           working: /homeException in thread background thread for pid 2431:   
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 2170, in background_thread
    handle_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1929, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 672, in handle_command_exit_code
    raise exc
ErrorReturnCode_2: 

  RAN: /home/kivy/.buildozer/android/platform/android-ndk-r9c/ndk-build V=1

  STDOUT:
/home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni/sdl/Android.mk:8: *** Please define SDL_JAVA_PACKAGE_PATH to the path of your Java package with dots replaced with underscores, for example "com_example_SanAngeles".  Stop.


  STDERR:


Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 978, in <module>
    main()
  File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 975, in main
    ToolchainCL()
  File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 512, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 149, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 193, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "pythonforandroid/build.py", line 573, in build_recipes
  File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/recipes/sdl2/__init__.py", line 32, in build_arch
    shprint(sh.ndk_build, "V=1", _env=env)
  File "pythonforandroid/logger.py", line 175, in shprint
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 720, in next
    self.wait()
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 651, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 672, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_2: 

  RAN: /home/kivy/.buildozer/android/platform/android-ndk-r9c/ndk-build V=1

  STDOUT:
/home/kivy/Projects/CalcGame/.buildozer/android/platform/build/build/bootstrap_builds/sdl2_gradle-python2/jni/sdl/Android.mk:8: *** Please define SDL_JAVA_PACKAGE_PATH to the path of your Java package with dots replaced with underscores, for example "com_example_SanAngeles".  Stop.


  STDERR:

# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=calcgame --bootstrap=sdl2 --requirements=kivy,operator,webbrowser,random,datetime,functools,android --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Projects/CalcGame/.buildozer/android/platform/build
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

这是 *** 上的一个已知问题:Buildozer build fails at NDK build giving SDL_JAVA_PACKAGE_PATH error。解决方案是删除所有与 kivy 相关的内容,然后从头开始。在我重新安装 Kivy Buildozer VM 之前,我将尝试构建其中一个示例项目,看看它是否会弹出相同的错误。

================================================ ============================

原文:

这周我用 kivy 编写了一个小计算游戏。现在基本功能正在运行,所以我想从我的应用程序中构建一个 apk 文件。调试此 apk 文件时出现我的问题。但我从头开始讲故事:

按照官方 kivy 文档,我安装了 virtual box(带有用于 USB 设备的扩展包)并导入了 Kivy/Buildozer VM。在正确输入密码(德语键盘上的“kivz”)并在构建过程中处理一个异常(buildozer.py 的某些行需要更改)后,我得到了一个 apk 文件。

在我的 Dropbox 帐户上上传 apk,在我的手机(Sony Xperia Z1)上下载它,在我的手机上安装“apk-installer”,通过 apk-installer 安装 CalculationGame。但游戏无法运行:如果您单击图标,屏幕会短暂变黑,然后退出应用程序并显示标准错误消息“Calculation game wurde leider bedet”。

接下来我尝试安装 Kivy Launcher 并通过此 Launcher 启动我的应用程序。它显示一个黑屏,中间有一个 kivy 标志,上面写着“正在加载...”。然后它崩溃了。不幸的是,我无法找到日志文件。它们应该位于“kivy/CalculationGame/.kivy/”。但是那个“.kivy”文件夹不是在我的手机上创建的。

所以我再次启动 Kivy/Buildozer VM,将我的手机连接到它并将我的手机设置为“调试模式”。 Kivy/Buildozer VM 直接识别出我的手机(创建了一个新的桌面图标)。然后我去终端,cd进入项目文件夹“home/kivy/Projects/CalcGame”(这是main.py和calculation.kv的文件夹,也是构建发生的文件夹,所以它有一个名为的子文件夹“build”,保存 apk 的位置)。在那个文件夹中,我运行了“buildozer android logcat”。它打印 3 行,然后等待电话。所以我看着我的手机,它问我是否要让一些电脑调试它。我当然说是的,然后终端窗口开始记录有线内容。除了其他有关我手机网络连接的信息(例如,我阅读了我的 wlan ssid)。但与我的应用程序无关。在几行之后,日志似乎又重复了一遍。

在此有线记录期间,我尝试了不同的事情:等待,在我的手机上启动 CalculationGame 应用程序,然后通过 Kivy-Launcher 应用程序启动我的应用程序。 Kivy/Buildozer VM 终端窗口中的输出没有任何影响。最终我用“strg+c”杀死了“buildozer android logcat”进程。然而,这会导致整个 Kivy/Buildozer VM 崩溃/冻结。

我感觉到构建/调试 apk 有一些非常基本的东西,我不理解,或者我的方法做错了。这是什么?

如果您需要有关我的代码/手机/android 版本/windows(10)/...的更多信息,请告诉我。

【问题讨论】:

请发布完整的adb logcat 日志,从应用程序启动到崩溃。 为完整的buildozer android logcat 日志创建了一个github repo。 @inclement 【参考方案1】:

回溯在您通过 github 发布的 logcat 日志中:

I/python  (11902):  Traceback (most recent call last):

I/python  (11902):    File "/home/kivy/Projects/CalcGame/.buildozer/android/app/main.py", line 495, in <module>

I/python  (11902):    File "/home/kivy/Projects/CalcGame/.buildozer/android/platform/build/dists/calcgame/private/lib/python2.7/site-packages/kivy/app.py", line 827, in run

I/python  (11902):    File "kivy/_event.pyx", line 714, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:8146)

I/python  (11902):    File "kivy/_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy/_event.c:14035)

I/python  (11902):    File "kivy/_event.pyx", line 1149, in kivy._event.EventObservers._dispatch (kivy/_event.c:13564)

I/python  (11902):    File "/home/kivy/Projects/CalcGame/.buildozer/android/app/main.py", line 445, in post_build_init

I/python  (11902):  ImportError: No module named android

解决方案是将android 添加到您的 buildozer.spec 中的需求行,或者从您的应用中删除对它的依赖。

这是一个很好的错误 - 这意味着该 apk 已成功构建。

【讨论】:

如果我在需求中指定android,那么构建过程会抛出错误。再次查看github。这是我在问题中已经提到的same error。某些SDL_JAVA_PKG_PATH 未定义。你有解决办法吗? 我仅将android 的依赖项用于“返回”按钮功能android.map_key(android.KEYCODE_BACK, 1000)。但是,如果我删除所有与android 相关的行(以及android 要求),则构建过程运行良好,并且我手机上的“返回”按钮仍然可以按预期工作。我不明白,但我暂时搁置它。如果有一天我需要android 上的dep,我会回来找你的。感谢您的帮助和耐心等待!【参考方案2】:

您的buildozer android logcat 命令应该构建您的应用程序并运行logcat,但您没有告诉它部署或运行​​您的应用程序。我想你想试试buildozer android deploy run logcat 之类的东西。您应该从您的项目文件夹(您的 buildozer.spec 文件所在的位置)运行它

【讨论】:

这并不重要。我的方法自动化程度较低:我必须在手机上手动安装 apk 并手动启动它。您建议的命令的优点是 CalculationGame 由命令的“运行部分”自动启动。但是,它有同样的基本问题:输出超过 10000 行,我不知道其中哪一行包含相关的调试输出。

以上是关于Kivy-Ubuntu 在“buildozer android logcat”之后崩溃的主要内容,如果未能解决你的问题,请参考以下文章

分配的变量引用在哪里,在堆栈中还是在堆中?

NOIP 2015 & SDOI 2016 Round1 & CTSC 2016 & SDOI2016 Round2游记

秋的潇洒在啥?在啥在啥?

上传的数据在云端的怎么查看,保存在啥位置?

在 React 应用程序中在哪里转换数据 - 在 Express 中还是在前端使用 React?

存储在 plist 中的数据在模拟器中有效,但在设备中无效