'kivy_garden.mapview module issues with buildozer (2022)

I get a problem while launching my app on android. It crashes while trying to open it on android. My app uses kivy and kivymd as a GUI. It also uses kivy_garden.mapview to display a map. It works perfectly fine on my PC.

I compile it via google collab virtual environment.

Concerning the buildozer.spec file I know that kivy_garden.mapview is no longer specified with these following lines:

#Garden requirements
garden_requirements = mapview

So I let it like this:

#Garden requirements
#garden_requirements =

I specified the kivy_garden.mapview module this way:

requirements = python3,kivy==2.0.0,kivymd==0.104.2,numpy,pillow,kivy_garden.mapview,openssl,requests

The compilation works fine and creates the .apk without any problem. But when I launch the app on Android, it crashes. I read in the MapView documentation the following advises:

Requirements : It requires the concurrent.futures and requests. If you use it on Android / iOS, don't forget to add openssl as a requirements, otherwise you'll have an issue when importing urllib3 from requests.

That's why there is "openssl" and "requests" in my requirements above in the .spec file.

My script (main.py) starts with these libraries imports:

import kivy
kivy.require('2.0.0')
import kivymd
from kivymd.uix.screen import MDScreen
from kivymd.app import MDApp
from kivy.uix.image import Image
from kivymd.uix.button import MDFillRoundFlatButton
from kivymd.uix.textfield import MDTextField
from kivymd.uix.label import MDLabel
from kivy_garden.mapview import MapView, MapSource, MapMarker
import numpy as np

Can someone tell me how to make working kivy garden mapview on android in 2022?

I created a version of my app without the "map functionnality", so everything as above except the kivy_garden.mapview module and it compiled and worked perfectly fine.



Solution 1:[1]

SOLVED HERE :

https://github.com/kivy-garden/mapview/issues/53

requirements = python3,kivy==2.0.0,kivymd==0.104.2,numpy,pillow,kivy_garden.mapview,openssl,requests,charset_normalizer,chardet,idna, urllib3,certifi

(certifi should be included already by default but no harm having it here just in case)

Solution 2:[2]

If you're using .kv file insert this code in the first line:

#:import MapView kivy_garden.mapview.MapView

After adding it, and all requirements in buildozer file, the app started working for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Iji
Solution 2 Jeremy Caney