Search code examples
androidkivy

kivy android app build with buildozer on WSL hanging in "Loading ..." state


I have done a small app using kivy that repeatedlly displays a stock quote, using yahooquery module. The app works on windows. I'd like to install this app on a xiamoi android smartphone and use buildozer on WSL to build the apk. The same app does not work on WSL for some OpenGL cause :

Here's the error message on WSL:

$ ./main.py
[INFO   ] [Logger      ] Record log in /home/ced/.kivy/logs/kivy_23-02-21_13.txt
[INFO   ] [Kivy        ] v2.1.0
[INFO   ] [Kivy        ] Installed at "/home/ced/.local/lib/python3.8/site-packages/kivy/init.py"
[INFO   ] [Python      ] v3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 189 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  148 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  76
  Current serial number in output stream:  77

Anyway, I've installed Buildozer on WSL and have run buildozer -v android debug. The build process produces an .apk file. When I install the .apk and run the app, it stays in 'Loading ...' state forever. Some xiaomi popup window displayed errors when the app was running:

Build fingerprint: 'Redmi/pissarropro_global/pissarropro:13

/TP1A.220624.014/V14.0.2.0.TKTMIXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2023-02-21 10:38:10.754735279+0100
Process uptime: 12s
Cmdline: ced.bart.bourse
pid: 23763, tid: 23811, name: hwuiTask1  >>> ced.bart.bourse <<<
uid: 10226
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: 'Failed to set damage region on surface 0xb400007b3a8f9580, error=EGL_NOT_INITIALIZED'
    x0  0000000000000000  x1  0000000000005d03  x2  0000000000000006  x3  0000007b20eba930
    x4  6b6b60621f6a626e  x5  6b6b60621f6a626e  x6  6b6b60621f6a626e  x7  7f7f7f7f7f7f7f7f
    x8  00000000000000f0  x9  0000007c68e54bb0  x10 0000000000000001  x11 0000007c68ec9b50
    x12 0000000000000018  x13 0000000063f49102  x14 00278d89826ac9a2  x15 00000887e4ec50f4
    x16 0000007c68f39a58  x17 0000007c68f12690  x18 0000007b1f478000  x19 0000000000005cd3
    x20 0000000000005d03  x21 00000000ffffffff  x22 0000007c5b033504  x23 0000000000000030
    x24 0000007b20ebab70  x25 0000007b20ebacb0  x26 0000007b20ebaff8  x27 00000000000fc000
    x28 00000000000fe000  x29 0000007b20eba9b0
    lr  0000007c68eb9d88  sp  0000007b20eba910  pc  0000007c68eb9db4  pst 0000000000001000
backtrace:
      #00 pc 000000000008cdb4  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 3908c7c57fa04c64df24425cf16523cf)
      #01 pc 000000000008ec3c  /apex/com.android.runtime/lib64/bionic/libc.so (fortify_fatal(char const, ...)+124) (BuildId: 3908c7c57fa04c64df24425cf16523cf)
      #02 pc 00000000000fcdec  /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t, char const)+60) (BuildId: 3908c7c57fa04c64df24425cf16523cf)
      #03 pc 00000000000fcc80  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_lock+208) (BuildId: 3908c7c57fa04c64df24425cf16523cf)
      #04 pc 00000000000fad8c  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_cond_wait+92) (BuildId: 3908c7c57fa04c64df24425cf16523cf)
      #05 pc 0000000000057094  /system/lib64/libc++.so (std::1::condition_variable::wait(std::1::unique_lock<std::1::mutex>&)+20) (BuildId: 52654de605ee801e350f35c2b4557dfa)
      #06 pc 000000000029cf48  /system/lib64/libhwui.so (android::uirenderer::CommonPool::workerLoop()+104) (BuildId: 5ce4a3a5cc37086cb0a6a27ec0178e25)
      #07 pc 000000000029d180  /system/lib64/libhwui.so (void std::1::thread_proxy<std::1::tuple<std::1::unique_ptr<std::1::thread_struct, std::1::default_delete<std::1::thread_struct> >, android::uirenderer::CommonPool::CommonPool()::$_0> >(void)+192) (BuildId: 5ce4a3a5cc37086cb0a6a27ec0178e25)
      #08 pc 00000000000fba4c  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_start(void)+204) (BuildId: 3908c7c57fa04c64df24425cf16523cf)
      #09 pc 000000000008e5f0  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 3908c7c57fa04c64df24425cf16523cf)

I have then tried to specify directly in .buildozer_spec the kivy version used 2.1.0 and reloaded the apk , but still the same problem: It hangs forever in "Loading..." state

Here's the small app code that works on windows and not on WSL:

#!/usr/bin/python
import datetime
from datetime import datetime
import yahooquery
from yahooquery import Ticker

import kivy
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button

class Bourse(App):
        def build(self):
                self.l=Label(text="Hello")
                self.layout = BoxLayout(padding=10)
                self.layout.add_widget(self.l)
                Clock.schedule_interval(self.def_cote,10)
                return self.layout
        def def_cote(self,*args):
                self.l.text=maj_cotes()

a=Ticker('ALLDL.PA')#LDLC
b=Ticker('COFA.PA')#COFACE

def maj_cotes():
        tl=a.price['ALLDL.PA']['regularMarketTime']
        tc=b.price['COFA.PA']['regularMarketTime']
        hl=str(tl.split()[1])
        hl=":".join(hl.split(":")[0:2])
        hc=str(tc.split()[1])
        hc=":".join(hc.split(":")[0:2])
        pl=a.price['ALLDL.PA']['regularMarketPrice']
        pc=b.price['COFA.PA']['regularMarketPrice']
        now=datetime.now()
        heure=now.strftime("%H:%M")
        cote_st=f"         COFACE {pc}€   ({hc})\n{heure}\n         LDLC {pl}€   ({hl})"
        return(cote_st)

bourse = Bourse()
bourse.run()

Using adb logcat -s python:

...
02-21 12:46:58.524  7275  7325 I python  : Android kivy bootstrap done. __name__ is __main__
02-21 12:46:58.524  7275  7325 I python  : AND: Ran string
02-21 12:46:58.524  7275  7325 I python  : Run user program, change dir and execute entrypoint
02-21 12:46:58.549  7275  7325 I python  : Traceback (most recent call last):
02-21 12:46:58.549  7275  7325 I python  :   File "/home/ced/programmation/python/kivy/kivy_bourse/.buildozer/android/app/main.py", line 4, in <module>
02-21 12:46:58.549  7275  7325 I python  :   File "/home/ced/programmation/python/kivy/kivy_bourse/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Bourse/arm64-v8a/yahooquery/__init__.py", line 6, in <module>
02-21 12:46:58.549  7275  7325 I python  :   File "/home/ced/programmation/python/kivy/kivy_bourse/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Bourse/arm64-v8a/yahooquery/research.py", line 4, in <module>
02-21 12:46:58.550  7275  7325 I python  : ModuleNotFoundError: No module named 'pandas'
02-21 12:46:58.550  7275  7325 I python  : Python for android ended

. Should'nt buildozer import pandas on its own? Thanks for your help !


Solution

  • Finally, I had to add every directly or indirectly imported module from main.py in requirements field of buildozer.spec I thought it was only necessary to add modules imported in main.py and that buildozer would add all the other imported modules from these modules, but it seems it doesnt