1

I'm building an app using kivy and it works perfectly on my Linux laptop. I build the app for android using buildozer and the log does not show any errors. When it was complete, the apk file is created in the bin folder.

I then copy the apk file and paste it on my phone storage and then install the app.

When I open the app, it shows the kivy logo and loading... but then it crashes! I tried the whole day to find a solution but I could not achieve that.

I find this command while googling the problem and it should be helpful for debugging but I can't understand the output!:

buildozer android logcat

This is the log that gets printed when I run this command

    # Ensure build layout
# Check configuration tokens
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.0.5 (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 /home/nidhal/.local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool
# Run '/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
List of devices attached

nidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ clear

nidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ buildozer android logcat
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.0.5 (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 /home/nidhal/.local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool
# Run '/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
List of devices attached

Furthermore, I tried to store the whole log when running the build using this command:

buildozer android debug deploy run logcat > log.txt

here is the log file

Moreover, here are the changes that I made to the default buildozer.spec file:

[app]

# (str) Title of your application
title = Overall Translator

# (str) Package name
package.name = overallTranslator

# (str) Package domain (needed for android/ios packaging)
package.domain = org.nidhal.overallTranslator

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,ttf

# (list) List of inclusions using pattern matching
source.include_patterns = assets/*,images/*.png, font/*.ttf

# (list) Source files to exclude (let empty to not exclude anything)
source.exclude_exts = spec, txt, md, gitignore

# (list) List of directory to exclude (let empty to not exclude anything)
source.exclude_dirs = tests, bin, venv

# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
#version = 0.1

# (str) Application versioning (method 2)
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = hostpython3==3.7.8,python3==3.7.8,kivy==1.11.1, beautifulsoup4, bs4, certifi,chardet,docutils, future, idna, Kivy-Garden, Pygments, requests, six, soupsieve, urllib3, deep-translator, arabic-reshaper, python-bidi, openssl

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (list) Garden requirements
#garden_requirements =

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait

# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 1.9.1

#

EDIT

here is the output of the logcat

Edit2: After resolving the no module found error adressed by @inclement, the app still crashes on my android phone. Here is the new logcat i receive when i run the app

basilisk
  • 1,156
  • 1
  • 14
  • 34
  • Post the logcat output, what you have posted doesn't seem to include that. – inclement Jul 12 '20 at 20:47
  • @inclement I provided a link for the whole output. Click the link (the log word) it will take you to the dropbox file – basilisk Jul 12 '20 at 21:13
  • It doesn't include the logcat log. – inclement Jul 12 '20 at 21:28
  • @inclement In the official documentation https://buildozer.readthedocs.io/en/latest/quickstart.html, it is clearly written that the logcat can be saved to a log.txt file when using that command. So that mean the log.txt content is the logcat output, which i provided in the link – basilisk Jul 12 '20 at 21:41
  • The logcat output is the log stream from the device. It looks like you never received anything. Since the last thing you do receive is an empty list of devices attached, do you actually have the device plugged in and with usb debugging enabled? – inclement Jul 12 '20 at 22:06
  • @inclement you are right! Thanks for the hint. I edited my question and included the logcat.txt file – basilisk Jul 12 '20 at 22:52

2 Answers2

1

Since the app is starting successfully, look in the logcat for lines containing the string "python". This will reveal the traceback:

07-13 00:47:44.658 27252 27350 I python  : [INFO   ] [Window      ] auto add sdl2 input provider
07-13 00:47:44.658 27252 27350 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
07-13 00:47:44.660 27252 27350 I python  :  Traceback (most recent call last):
07-13 00:47:44.660 27252 27350 I python  :    File "/home/nidhal/Desktop/my_code/deep-translator-app/.buildozer/android/app/main.py", line 5, in <module>
07-13 00:47:44.661 27252 27350 I python  :    File "/home/nidhal/Desktop/my_code/deep-translator-app/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/overalltranslator/deep_translator/__init__.py", line 3, in <module>
07-13 00:47:44.661 27252 27350 I python  :    File "/home/nidhal/Desktop/my_code/deep-translator-app/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/overalltranslator/deep_translator/google_trans.py", line 5, in <module>
07-13 00:47:44.661 27252 27350 I python  :  ModuleNotFoundError: No module named 'bs4'
07-13 00:47:44.661 27252 27350 I python  : Python for android ended.

Beautifulsoup4 needs a python-for-android build recipe to work, but I don't think there currently is one (although your problem seems to be more generically that you didn't include it at all).

inclement
  • 29,124
  • 4
  • 48
  • 60
  • @inclememt oh I didn't notice that log at all! But it's weird since I'm including beautifulsoup under requirements in the buildozer.spec file as you can see above in the description. Did I miss something in the .spec file maybe? Did I write the requirements in a wrong way? – basilisk Jul 13 '20 at 05:09
  • I don't know, but it's still the case that it probably won't work without a build recipe in python-for-android. – inclement Jul 13 '20 at 10:24
  • I was able to solve that no module named error after I placed the bs4 in the requirements. The app still crashes on my phone. I posted the new logcat output, it looks like I dont have any no module named errors anymore. I'm hopeless I have no idea why the app is crashing – basilisk Jul 13 '20 at 20:18
0

After days of debugging, I finally find the error, which is caused by some third party libraries that I used in my project. Obviously, kivy, buildozer or python-for-android could not parse this (I don't know how the packaging is done).

If anyone is having this problem, I highly recommend debugging with an emulator and not relying on the logcat. In my case the logcat was useless. It did not tell me nothing about the error.

I needed to try step by step removing dependencies until I found the error. Answer and comment of @inclement were also helpful.

basilisk
  • 1,156
  • 1
  • 14
  • 34