Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flet==0.25.2 "Android" Apk Does not run with Numpy "Emulator" or real device Android 14 or 15 #4637

Open
1 task done
JCxOx opened this issue Dec 28, 2024 · 0 comments
Open
1 task done

Comments

@JCxOx
Copy link

JCxOx commented Dec 28, 2024

Duplicate Check

Describe the bug

Dear developper,

The error I have is similar to error described in #4198 , #4203,
After reinstalling all tools and software from scratch, I finally generated the APK, but the app doesn't work.

(venv) C:\Users\JeanClaude\Documents\Flet\map_ortho_shp>flet build apk
[17:56:28] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.25.2 ✅
Customized app icons and splash images ✅
[17:56:31] Generated app icons ✅
[17:56:32] Generated splash screens ✅
[17:57:46] Packaged Python app ✅
[17:58:22] Built .apk for Android ✅
Copied build to build\apk directory ✅
Successfully built your .apk for Android! 🥳 Find it in build\apk directory. 📁

The pyproject.toml :

[project]
name = "map_ortho_shp"
version = "1.1.0"
description = ""
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"flet==0.25.2",
"numpy",
"flet.map",
"shapely"
]

But in Android emulator, the following error appears with android 13 or 14 (API 33 or 34, Pixel 8 device).
... ImportError: dlopen failed: library "libc++_shared.so" not found ...

details here from the emulated phone :

"
Traceback (most recent call last):
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/_core/init.py", line 23, in
from . import multiarray
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/_core/multiarray.py", line 10, in
from . import overrides
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/_core/overrides.py", line 8, in
from numpy._core._multiarray_umath import (
ImportError: dlopen failed: library "libc++_shared.so" not found: needed by /data/data/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/_core/_multiarray_umath.cpython-312.so in namespace classloader-namespace

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/init.py", line 114, in
from numpy.config import show as show_config
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/config.py", line 4, in
from numpy._core._multiarray_umath import (
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/_core/init.py", line 49, in
raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.12 from ""
  • The NumPy version is: "2.1.1"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen failed: library "libc++_shared.so" not found: needed by /data/data/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/_core/_multiarray_umath.cpython-312.so in namespace classloader-namespace

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/numpy/init.py", line 119, in
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
Traceback (most recent call last):
File "", line 47, in
File "", line 229, in run_module
File "", line 88, in _run_code
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/app/main.py", line 20, in
from shapely.geometry import Point, Polygon
File "/data/user/0/com.mycompany.map_ortho_shp/files/flet/python_site_packages/shapely/init.py", line 1, in
from shapely.lib import GEOSException # NOQA
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy._core.multiarray failed to import
"

On the real phone, nothing is displayed , only white screen.

The application run correctly on Window (with the command : flet run)

I don't know how to solve this problem,
If you have a solution, please tell me !

Thanks a lot,

JC

Code sample

Code
import flet as ft
import flet.map as map
import math
import sys
import shapefile
from shapely.geometry import Point, Polygon

To reproduce

Generic error when numpy is used

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 10

Flet version

Name: flet Version: 0.25.2 Summary: Flet for Python - easily build interactive multi-platform apps in Python Home-page: https://flet.dev Author: Appveyor Systems Inc. Author-email: [email protected] License: Apache-2.0 Location: C:\Users\JeanClaude\Documents\Flet\venv\Lib\site-packages Requires: httpx, oauthlib, repath Required-by: flet-cli, flet-desktop

Regression

No, it isn't

Suggestions

As the error comes from : ImportError: dlopen failed: library "libc++_shared.so" not found...

Add the missing file "libc++_shared.so" to the APK

Logs

Logs
[Paste your logs here]

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant