Search code examples
pythonandroidkivybuildozer

I have problems opening my app on Android after using Kivy/Buildozer


I'm working on an android app project that will ultimately use OpenCV (didn't reach that part yet). I only finished the functionality part of the project but it keeps crashing as soon as it opens on my Android phone (Haewai P20). Before that, I did the famous "Hello world" test and the app showing these 2 words opened fine. I read a lot of forums but can't find any solutions.

I'm working on PyCharm with python 3.7 and the app works fine when I'm opening it on Windows. Then I'm using buildozer on Ubuntu 18.04 on VirtualBox 6.0.6.

I didn't wanted to copy paste all my logcat, buildozer.spec and log files so you can have a look at them here:

buildozer.spec:

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

log.txt created with buildozer:

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

logcat.txt (only the part where I installed it and opened it):

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

I'm not sure exactly what to look at. I have a feeling that there's an incompatibility between Python versions (buildozer uses 2.7) but I'm not sure how to deal with that. If it's really the problem.

Please let me know if you have problems opening these files and if you need anything else.

Thank you very much in advance for your help and time.


Solution

  • How to search for error in logcat?

    Either search for "I python" using an editor or buildozer android debug deploy run > grep "I python"

    Logcat3.txt - Error

    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.
    

    Problem

    Your buildozer.spec is missing dependencies ['numpy', 'pytz', 'dateutil']

    Solution

    Add dependencies ['numpy', 'pytz', 'dateutil'] to requirements in buildozer.spec

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

    Logcat1.txt - Error

    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.
    

    Problem

    1. In your buildozer.spec, you specified Kivy version 1.11.1 and Python 2 but in your Kivy app, (main.py), it has 1.11.0
    2. Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore

    Solution

    1. Either remove the following in main.py or change it to '1.11.1' (i.e. same as buildozer.spec)
        import kivy
        kivy.require('1.11.0')
    
    1. If you want to use Kivy version 1.11.1, you have to replace python2 with python3 for requirements