flet
flet copied to clipboard
flet==0.25.0.dev3526 apk "Android" error matplotlib "libjpeg.so" not found
Duplicate Check
- [X] I have searched the opened issues and there are no duplicates
Describe the bug
After building apk with Matplotlib package and running it on Android device simulator, error when trying to import matplotlib: dlopen failed: library "libjpeg.so" not found: needed by /data/data/com.flet.matplotlib_app/files/flet/python_site_packages/PIL/_imaging.cpython-312.so in namespace classloader-namespace
Code sample
Code
import flet as ft
def main(page: ft.Page):
page.title = "Flet libs test"
def matplotlib_tests(e):
def test_basic():
try:
import matplotlib
page.add(ft.Text("import matplotlib: OK"))
import matplotlib.pyplot as plt
from flet.matplotlib_chart import MatplotlibChart
matplotlib.use("svg")
fig, ax = plt.subplots()
fruits = ["apple", "blueberry", "cherry", "orange"]
counts = [40, 100, 30, 55]
bar_labels = ["red", "blue", "_red", "orange"]
bar_colors = ["tab:red", "tab:blue", "tab:red", "tab:orange"]
ax.bar(fruits, counts, label=bar_labels, color=bar_colors)
ax.set_ylabel("fruit supply")
ax.set_title("Fruit supply by kind and color")
ax.legend(title="Fruit color")
page.add(MatplotlibChart(fig, expand=True))
plt.figure()
plt.plot([1, 2])
bio = io.BytesIO()
plt.savefig(bio, format="png")
b = bio.getvalue()
EXPECTED_LEN = 16782
assert len(b) > int(EXPECTED_LEN * 0.8)
assert len(b) < int(EXPECTED_LEN * 1.2)
assert b[:24] == (
b"\x89PNG\r\n\x1a\n"
+ b"\x00\x00\x00\rIHDR" # File header
+ b"\x00\x00\x02\x80" # Header chunk header
+ b"\x00\x00\x01\xe0" # Width 640 # Height 480
)
page.add(ft.Text("matplotlib: test_basic - OK"))
except Exception as e:
page.add(
ft.Text(f"matplotlib: test_basic - error: {e}", selectable=True)
)
test_basic()
page.add(
ft.SafeArea(
ft.Column(
[
ft.ElevatedButton(
"Run Matplotlib tests", on_click=matplotlib_tests
),
]
)
)
)
ft.app(main)
pyproject.toml
[project]
name = "matplotlib_app"
version = "1.0.0"
description = ""
authors = [{name = "Flet Developer", email = "[email protected]"}]
dependencies = ["flet==0.25.0.dev3526", "matplotlib"]
[tool.flet]
android.adaptive_icon_background = "#ffffff"
To reproduce
- flet build apk
- install apk on android device
- click on "Run Matplotlib tests" button
Expected behavior
Expected to see MatplotlibChart
Screenshots / Videos
Captures
[Upload media here]
Operating System
macOS
Operating system details
Sequoia 15
Flet version
flet==0.25.0.dev3526
Regression
No, it isn't
Suggestions
No response
Logs
Logs
[Paste your logs here]
Additional details
No response