Error CV2 Lib in My Application (APK)
Duplicate Check
- [x] I have searched the opened issues and there are no duplicates
Describe the bug
When I install the CV2 library, the phone application does not work and shows me an error. I followed the steps in #4850, but with the same result. I have had this problem for six months, and I have tried many things, but to no avail.
so I need clear steps that solve this problem, please.
Code sample
from flet import * import cv2
def main(page:Page): page.appbar = AppBar(title=Text("Test"),bgcolor=Colors.BLUE,center_title=True)
page.add(Row([Text(f"Libarary Name :{cv2.__name__}")],alignment=MainAxisAlignment.CENTER),
Row([IconButton(icon=Icons.PHONE_ANDROID,on_click= lambda e: page.launch_url("geo:31.4528795,31.699601"))],alignment=MainAxisAlignment.CENTER)
) page.update()
app(target=main,assets_dir= r"D:\Python\Flet - Cross Platform\alderly\assets")
To reproduce
**explain how to include these libs like cv2 in the Docu
Expected behavior
https://flet.dev/docs/reference/binary-packages-android-ios/
in this link it's appear that open CV is available for Android and ios so I built apk but it same error
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
Windows 10 pro
Flet version
flet 0.27.6
Regression
No, it isn't
Suggestions
i just need how to make cv2 run in my application and how to use .whl files downloaded with cv2 that were Developed by Flet Developers
Logs
No response
Additional details
-- pyproject.toml file for this project
[project] name = "testapi" version = "0.0.0.04" description = "" authors = [ {name = "Your Name",email = "[email protected]"} ]
dependencies = [ "opencv_python==4.10.0.84", "flet==0.27.6", ]
[tool.flet.android.permission] # --android-permissions
"android.permission.CAMERA" = true "android.permission.ACCESS_FINE_LOCATION" = true "android.permission.ACCESS_COARSE_LOCATION" = true "android.permission.ACCESS_BACKGROUND_LOCATION" = true "android.permission.RECORD_AUDIO" = true "android.permission.WRITE_EXTERNAL_STORAGE" = true "android.permission.READ_EXTERNAL_STORAGE" = true
[tool.flet.app.boot_screen] show = true message = "Preparing the app for its first launch…"
[tool.flet.app.startup_screen] show = true message = "Starting up the app…"
[tool.flet.compile] app = true packages = false
[tool.flet.android.feature] # --android-features "android.hardware.camera" = true "android.hardware.location.network" = false "android.hardware.location.gps" = false
Hello @Youssef3082004 Have you found a solution ? Thanks !
@brieucpopper for Sorry until now; no, I tried many solutions but failed, but there is a solution, but I don't know how to implement it
there is comment link: CV2 Solution
@Youssef3082004 Not exactly sure what I did but i can now open the .apk on my phone withotu it crashing :
https://github.com/brieucpopper/example_app
im continuing to progress but if you use UV and my pyproject.toml exactly, maybe you can try to run uv run flet build apk and it will work for you too?
@brieucpopper Oh Good! I starred your repo, and I will try it and inform you
- But the question here if open cv functions will work or not in .apk. Have you tried it before?