flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.56k stars 452 forks source link

Sqlite3 - C-Library (?) not packed to APK #4191

Closed nonexus closed 1 month ago

nonexus commented 1 month ago

Duplicate Check

Describe the bug

Please bear with me - this is my first use of Github ever. Until know I've been a silent reader :) For flet=0.25.0.dev3526 building of apk from Linux or Windows works fine, but then raises an error while starting on android:

Traceback (most recent call last):
  File "<string>", line 43, in <module>
  File "<frozen runpy>", line 229, in run_module
  File "<frozen runpy>", line 88, in _run_code
  File "/data/user/0/com.flet.myapp/files/flet/app/main.py", line 3, in <module>
    import sqlite3
  File "./sqlite3/__init__.py", line 57, in <module>
  File "./sqlite3/dbapi2.py", line 27, in <module>
ModuleNotFoundError: No module named '_sqlite3'

After a little of googling it seems that while sqlite3 is part of python, the c-libraries (_sqlite3) need to be compiled for arm and included?

Code sample

import flet as ft
import sqlite3

def main(page: ft.Page):
    page.add(ft.SafeArea(ft.Text("Hello, Flet!")))
    conn = sqlite3.connect("mydb.db")
    cursor = conn.cursor()

ft.app(main)

To reproduce

import flet as ft
import sqlite3

def main(page: ft.Page):
    page.add(ft.SafeArea(ft.Text("Hello, Flet!")))
    conn = sqlite3.connect("mydb.db")
    cursor = conn.cursor()

ft.app(main)

Expected behavior

Code should run and open the connection to sqlite3 database

Screenshots / Videos

No response

Operating System

Windows

Operating system details

Windows 11, also Ubuntu

Flet version

0.25.0.dev3526

Regression

I'm not sure / I don't know

Suggestions

I guess this is most probably a part of the new packaging process (which I absolute love! Please keep up the absolutely stunning work!)

Logs

No response

Additional details

No response

FeodorFitsner commented 1 month ago

Looking into that.

FeodorFitsner commented 1 month ago

It should be fixed now.

Before re-building your app delete build directory inside app folder.