0

LAST EDIT FOR TODAY:

Created a github repo for the log files of "buildozer android logcat" and "buildozer android debug deploy run logcat".

Deleted my answer, where I posted a small part of this log file.

EDIT 18.03.2018:

I'm back at the problem with which I started this thread: I can launch my app via the Kivy Launcher, I can build an apk file from my source code, I can install this apk file. But I cannot debug this apk file (see below for my original message).

I found out that you can log the terminal history (commands + output) using "script -a history_for_stackoverflow.txt". However less than one minute of runtime of the process "buildozer android logcat" produce more that 600000 (six hundred thousand) characters of logging. And apparantly stackoverflow questions have a maximum of 30000 characters.

I will post the first part of the log file as an answer to my own question. But as I mentioned in my original message, to me the output seems to be highly repetitive and unrelated to my app. Both starting and crashing of my app (during the logcat process) do not seem to have any effect on the output in the terminal window. And I cannot exclude that the intesting part (where my app is started/where it crashes) is part of the log that I can post here.

Please let me know if I may write you an email with the full log file. Any other suggestions are welcome!

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

EDIT 18.03.2018:

Okay, I tried some more things: I can build an apk file from the kivy-example "touchtracer" app. There are no errors during "buildozer andoid debug". So the buildozer-vm seems to be okay. Since the build-process works with the example app, it is obvious that the problem is not the buildozer-vm, but my app/code.

The touchtracer app depends on math and random module. So in a second try, I included those libraries in the buildozer.spec file in the requirements line. Doing thins breaks the build process. So I suppose that standard libraries do not have to be specified in buildozer.spec file. This could be the first reason why my build process is not working anymore (I do specify operator, webbrowser, random, etc. in the buildozer.spec file of my CalculationGame).

Meanwhile I found the log files of Kivy-Launcher in the file system of my phone: "kivy/CalculationGame/.kivy/logs/*.txt". They suggest that my app crashes because of bad super().init statements. I use the python 3 notation, where you don't have to specify the subclass as a parameter of the super() call. In python 2, however, you need to do that.

Do I have to switch to python 2 notation? Maybe there is some line in buildozer.spec file, where I can define that kivy should expect python 3 code?

For the sake of completeness I post the log file of "Kivy Launcher" launching my 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)

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

EDIT 18.03.2018:

I use some standard python libraries in my app (operator, datetime, functools, etc.) and I did not specify them in my buildozer.spec file. I think this could be the reason why the app crashes on my phone instantly.

However, now that I have specified the libraries in my buildozer.spec file, the build process "buildozer android debug" runs into an error:

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

This is a known problem on stackoverflow: Buildozer build fails at NDK build giving SDL_JAVA_PACKAGE_PATH error. The solution was to delete everything kivy-related and to then start from scratch. Before I re-install the Kivy Buildozer VM, I will try to build one of the example projects and see if it pops the same error.

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

Original Message:

This week I programmed a little calculation game in kivy. Now the basic functionalities are working, so I want to build an apk-file from my app. My problems arise when debugging this apk file. But I start the story from the beginning:

Following the official kivy docs I installed virtual box (with extension pack for usb devices) and imported the Kivy/Buildozer VM. After getting the password right (it is "kivz" on german keyboard) and dealing with one exception during the build process (some lines of buildozer.py needed changes) I got an apk file.

Uploaded the apk on my dropbox account, downloaded it on my phone (Sony Xperia Z1), installed "apk-installer" on my phone, installed CalculationGame via the apk-installer. But the game won't work: If you click on the icon, the screen turns black for a short time and then the app is exited with the standard error message "Calculation game wurde leider beendet".

Next thing I tried was installing Kivy Launcher and starting my app via this Launcher. It shows a black screen with the kivy logo in the center saying "Loading...". Then it crashes. Unfortunately I am not able to find the log files. They should be located at "kivy/CalculationGame/.kivy/". But that ".kivy"-folder is not created on my phone.

So I startet the Kivy/Buildozer VM again, connected my phone to it and set my phone to "debug modus". Kivy/Buildozer VM directly recognized my phone (a new desktop icon was created). Then I went to the terminal and cd into the project folder "home/kivy/Projects/CalcGame" (this is the folder with main.py and calculation.kv, but also the folder where the build happend, so it has a subfolder called "build", where the apk is saved). In that folder I ran "buildozer android logcat". It prints 3 lines and then waits for the phone. So I looked at my phone and it asked me whether I want to allow some PC to debug it. I said yes of course and then the terminal window startet to log wired stuff. Among others information about the network connection of my phone (I read my wlan ssid for example). But nothing related to my app. And the log seemed to repeat itself after some lines.

During this wired logging I tried different things: just waiting, starting the CalculationGame app on my phone and starting my app through Kivy-Launcher app. Nothing had any effect on the output in Kivy/Buildozer VM terminal window. Eventually I kill the "buildozer android logcat"-process with "strg+c". This however leads to the whole Kivy/Buildozer VM crashing/freezing.

I sense that there is something very basic about building/debugging apk's that I do not understand or that I am doing wrong in my approach. What is it?

Let me know if you need more information about my code/phone/android version/windows(10)/...

J. Katzer
  • 97
  • 1
  • 7
  • Please post the full `adb logcat` log from when the app is started to when it crashes. – inclement Mar 16 '18 at 22:56
  • Created a [github repo](https://github.com/der-spaete-jo/CalculationGame) for the full `buildozer android logcat` log. @inclement – J. Katzer Mar 18 '18 at 15:33

2 Answers2

0

Your buildozer android logcat command should build your app and run logcat, but you didn't tell it to deploy or run your app. I think you want to try something like buildozer android deploy run logcat. And you should run it from your project folder (where your buildozer.spec file is located)

John Anderson
  • 35,991
  • 4
  • 13
  • 36
  • It doesn't really matter. My approach is less automated: I have to manully install the apk on my phone and manually start it. The command that you suggest has the advantage that CalculationGame is started automatically by the "run-part" of the command. However, it has the same basic problem: the output is over 10000 lines and I don't know which of these lines contains the relevant debugging output. – J. Katzer Mar 18 '18 at 13:44
0

The traceback is in the logcat log you posted via github:

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

The solution is to add android to the requirements line in your buildozer.spec, or to remove the dependency on it from your app.

This is a good error though - it means that the apk has otherwise been built successfully.

inclement
  • 29,124
  • 4
  • 48
  • 60
  • If I specify `android` in the requirements, then the build process throws an error. See [github](https://github.com/der-spaete-jo/CalculationGame/blob/master/debug%20with%20android%20requirement) again. It is the [same error](https://stackoverflow.com/questions/48302431/buildozer-build-fails-at-ndk-build-giving-sdl-java-package-path-error) that I already mentioned in my question. Some `SDL_JAVA_PKG_PATH` is not defined. Do you have a workaround for this? – J. Katzer Mar 19 '18 at 08:09
  • I use the dependency on `android` only for the 'back'-Button functionality `android.map_key(android.KEYCODE_BACK, 1000)`. However, if I remove all `android`-related lines (and the `android` requirement), the build process runs fine and the 'back'-Button on my phone still works as expected. I don't understand that, but I leave it be for now. If one day I need the dep on `android`, I will come back to you. Thank you for your help & patience! – J. Katzer Mar 19 '18 at 08:36