kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.13k stars 1.82k forks source link

rust recipe shazamio-core, builds fine, but cannot locate symbol __gxx_personality_v0 #3030

Open magowiz opened 3 weeks ago

magowiz commented 3 weeks ago

Checklist

Versions

Description

I was trying to add to my project a shazamio-core recipe which is a rust project, so I used the recipe class RustCompiledComponentsRecipe and wrote my own recipe, which is this:

from pythonforandroid.recipe import RustCompiledComponentsRecipe

class ShazamIoCoreRecipe(RustCompiledComponentsRecipe):
    version = "1.0.7"
    url = (
        f"https://github.com/shazamio/shazamio-core/archive/refs/tags/{version}.tar.gz"
    )
    site_packages = "shazamio_core"

recipe = ShazamIoCoreRecipe()

It compiles fine, but in android, when I launch my app I get this import error:

ImportError: dlopen failed: cannot locate symbol "__gxx_personality_v0" referenced by "/data/data/net.magowiz.musenote/files/app/_python_bundle/site-packages/shazamio_core/shazamio_core.so"...

then the app crashes

buildozer.spec

Command:

buildozer android debug

Spec file:

title = MuseNote
package.name = musenote
package.domain = net.magowiz
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
source.exclude_dirs = tests, bin, venv, source
version = 0.1
requirements = python3,kivy,kivymd,androidstorage4kivy,bawx-player,mutagen,ffpyplayer==v4.5.1,ffpyplayer_codecs,ffmpeg,
    sqlalchemy,alembic,typing_extensions,mako,markupsafe,pydantic,dataclass_factory,aiohttp_retry,aiohttp,multidict,
    attrs,yarl,async_timeout,charset_normalizer==2.1.1,faust-cchardet,aiosignal,frozenlist,pydub,shazamio_core,annotated_types,
    https://github.com/andreyzin/ShazamIO/archive/refs/heads/bump-pydantic2.zip,pydantic-core
presplash.filename = %(source.dir)s/img/icon.png
icon.filename = %(source.dir)s/img/icon.png
orientation = portrait, landscape
osx.python_version = 3
osx.kivy_version = 1.9.1
fullscreen = 0
android.permissions = STORAGE, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE, INTERNET,MANAGE_EXTERNAL_STORAGE,READ_MEDIA_IMAGES,READ_MEDIA_VIDEO,READ_MEDIA_AUDIO
android.api = 34
android.archs = arm64-v8a, armeabi-v7a, x86, x86_64
android.allow_backup = True
p4a.fork = kivy
p4a.branch = develop
p4a.local_recipes = p4a_recipes
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.10.0
ios.codesign.allowed = false
[buildozer]
log_level = 2
warn_on_root = 0

Logs

no errors on building

T-Dynamos commented 3 weeks ago

Maybe you try to play with linking flags in get_recipe_env and add -lstdc++.

Something like:

    def get_recipe_env(self, arch, **kwargs):
        env = super().get_recipe_env(arch, **kwargs)
        env['LDFLAGS'] += ' -lstdc++'
        return env
magowiz commented 3 weeks ago

Hi @T-Dynamos, thanks for the hint, I changed the recipe in this way, like you suggested:

from pythonforandroid.recipe import RustCompiledComponentsRecipe

class ShazamIoCoreRecipe(RustCompiledComponentsRecipe):
    version = "1.0.7"
    url = (
        f"https://github.com/shazamio/shazamio-core/archive/refs/tags/{version}.tar.gz"
    )
    site_packages = "shazamio_core"

    def get_recipe_env(self, arch, **kwargs):
        env = super().get_recipe_env(arch, **kwargs)
        env['LDFLAGS'] += ' -lstdc++'
        return env

recipe = ShazamIoCoreRecipe()

I deleted buildozer home and build folders and built again, with new recipe, it builds successfully, but I still get same behavior: app crashes and on log there is same error.

magowiz commented 3 weeks ago

Hi, mantainer provided in a release in github some whl files https://github.com/shazamio/shazamio-core/releases , for example this: https://github.com/shazamio/shazamio-core/releases/download/1.0.7/shazamio_core-1.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

How can I create a recipe that install from there ?

T-Dynamos commented 3 weeks ago

@magowiz This can't be used, as it's compiled for glibc, but android is bionic.

(Only wheels compiled with android-ndk will work)

T-Dynamos commented 3 weeks ago

I believe this error can be easily solved, I will try work on it ASAP.

magowiz commented 3 weeks ago

thank you very much!

magowiz commented 5 days ago

I believe this error can be easily solved, I will try work on it ASAP.

Hi, is there news about it?