flet icon indicating copy to clipboard operation
flet copied to clipboard

No file or variants found for asset: app/app.zip error with `flet build apk` on Windows

Open Heoder opened this issue 2 years ago • 19 comments

I have error error

Heoder avatar Jan 08 '24 02:01 Heoder

The actual error is No file or variants found for asset: app/app.zip. Those "errors" are warnings.

Could you run flet build apk -vv to get a detailed log?

FeodorFitsner avatar Jan 08 '24 18:01 FeodorFitsner

Vietnamese: Tôi đã khắc phục được do phiên bản python tôi dùng là 13.12 tôi đã down xuống 13.11.6 và đã build OK. Làm sao tôi có thể build cho phiển bản andoird 7. 8. 9, 10, 11.... English: I was able to fix it because the python version I used was 13.12, I downloaded it to 13.11.6 and it built OK. How can I build for Android version 7. 8. 9, 10, 11....

Heoder avatar Jan 09 '24 02:01 Heoder

You mean Python 3.12 and 3.11.6?

FeodorFitsner avatar Jan 09 '24 03:01 FeodorFitsner

You mean Python 3.12 and 3.11.6?

I downgrade python to 3.11.6

Heoder avatar Jan 09 '24 03:01 Heoder

log.txt this is my log file, When I install it on the device, the screen is blank screenshot_blank

Heoder avatar Jan 09 '24 03:01 Heoder

What other Python dependencies does your app require, except flet?

FeodorFitsner avatar Jan 09 '24 04:01 FeodorFitsner

What other Python dependencies does your app require, except flet? include: import pyodbc, json import time, requests

Heoder avatar Jan 09 '24 04:01 Heoder

@akunzz Give your requirements.txt

taaaf11 avatar Jan 09 '24 09:01 taaaf11

@akunzz Give your requirements.txt

anyio==4.2.0 arrow==1.3.0 binaryornot==0.4.4 blinker==1.7.0 certifi==2023.11.17 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 cookiecutter==2.5.0 Flask==3.0.0 flet==0.18.0 flet-core==0.18.0 flet-runtime==0.18.0 h11==0.14.0 httpcore==0.17.3 httpx==0.24.1 idna==3.6 itsdangerous==2.1.2 Jinja2==3.1.2 markdown-it-py==3.0.0 MarkupSafe==2.1.3 mdurl==0.1.2 oauthlib==3.2.2 packaging==23.2 Pygments==2.17.2 pyodbc==5.0.1 pyotp==2.9.0 pypng==0.20220715.0 python-dateutil==2.8.2 python-slugify==8.0.1 PyYAML==6.0.1 qrcode==7.4.2 repath==0.9.0 requests==2.31.0 rich==13.7.0 six==1.16.0 sniffio==1.3.0 text-unidecode==1.3 types-python-dateutil==2.8.19.20240106 typing_extensions==4.9.0 urllib3==2.1.0 watchdog==3.0.0 websocket-client==1.7.0 websockets==11.0.3 Werkzeug==3.0.1

Heoder avatar Jan 09 '24 09:01 Heoder

@akunzz By looking at the requirements list you gave, it seems you are using flet, Flask and pyodbc packages (the top level) right? Make your requirements.txt hand-picked, and list only direct imports in requirements.txt. Like I said before, the requirements.txt would seem like (only including direct imports from your files)

flet
Flask
pyodbc

version you give

Try this

taaaf11 avatar Jan 09 '24 10:01 taaaf11

@akunzz By looking at the requirements list you gave, it seems you are using flet, Flask and pyodbc packages (the top level) right? Make your requirements.txt hand-picked, and list only direct imports in requirements.txt. Like I said before, the requirements.txt would seem like (only including direct imports from your files)

flet
Flask
pyodbc

version you give

Try this

ok let me try, in my project I import include: import time import requests import pyodbc,json

Heoder avatar Jan 09 '24 11:01 Heoder

import pyodbc,json

class Database:
    def __init__(self):
        self.conn_str = (
            r'DRIVER={SQL Server};'
            r'SERVER=xx.xxx.xxxx;'
            r'DATABASE=xxxxxxx;'
            r'UID=xxxxx;'
            r'PWD=xxxxxx'
        )

    def execute_query(self, query):
        print(query)
        conn = pyodbc.connect(self.conn_str)
        cursor = conn.cursor()
        cursor.execute(query)
        cursor.commit()
        conn.close()

    def fetch_query(self, query):
        conn = pyodbc.connect(self.conn_str)
        cursor = conn.cursor()
        cursor.execute(query)
        rows = cursor.fetchall()
        #print(rows)
        if len(rows)!= 0:
            result = [dict(zip([column[0] for column in cursor.description], row)) for row in rows]
            conn.close()
            json_result = json.dumps(result)
            decoded_result = json.loads(json_result)
            return decoded_result
        else:
            conn.close()
            return None

from config.database import Database



class Login:
    def __init__(self):
        self.q = Database()

    def login(self, user:str, password:str):
        if user[0]=='1':
            query = "select xxx"
        else:
            query="xxxxx"
        return self.q.fetch_query(query)
    
    def get_profile(self, manv:str):
        query="select * from o_profile where manv=N'"+manv+"'"
        return self.q.fetch_query(query)
    
    def set_user(self, manv:str, str_cl:str, str_v:str):
        query="update o_profile set "+str_cl+"='"+str_v+"' where manv=N'"+manv+"'"
        self.q.execute_query(query)
from flet import *
from services.login import Login
 username = self.txt_username.value
        password = self.txt_password.value
        q = Login()
        data_login = q.login(username,password)
        if data_login != None:
            if str(data_login[0]['lamviec'])=='0':
                self.page.splash.visible = False
                self.show_ms(icons.ERROR_OUTLINE,'Nhân viên này đã nghỉ việc', colors.RED)
            else:
                self.page.client_storage.set('login', data_login)
                self.page.splash.visible = False
                self.on_store_pass
                self.callback()
                print('vào main')
        else:
            self.page.splash.visible = False
            self.show_ms(icons.ERROR_OUTLINE,'Tài khoản hoặc mật khẩu không đúng', colors.RED)

When I remove from services.login import Login and don't use it anymore, the app won't get a black screen, so I suspect it's in the import pyodbc package. even though my requirements.txt file is flet pyodbc

Heoder avatar Jan 09 '24 13:01 Heoder

@akunzz I forgot to tell, add requests in your requirements.txt file. My connection was gone 😅.

From my experience, that "unresponsive" screen is caused by some error or warning thingies going on in python code. Check if you can execute this code on the computer or laptop you are coding on without any warning or anything like that.

And... hah! I got it!!! 😎 can you look at the last code block you gave??? 😏

Look at that username = self.txt_username.value in third line.

This space (indent) at the start of the line might be causing the problem...

And, by the way, why implement another class Login? When you can implement the methods in Database class...

p.s: Why the code in the last block is so badly indented?

Edit: Mention, clarify

taaaf11 avatar Jan 09 '24 15:01 taaaf11

OK, guys, the problem is in pyodbc module which is non-pure Python module with parts written in C. I went through its sources and looks like it heavily depends on underlying platform-specific ODBC drivers. I don't see an easy way to use that on a mobile device.

Architecturally, it would be more right having a backend service running on the server and a mobile app accessing that service via HTTP/sockets. Backend service in its turn uses ODBC to make low-level calls to the database and exposes high-level API to your mobile app. Also, your mobile app cannot contain database connection string details (or any other private/sensitive) as anyone can retrieve that data from the app package.

Hope that helps.

FeodorFitsner avatar Jan 09 '24 17:01 FeodorFitsner

OK, guys, the problem is in pyodbc module which is non-pure Python module with parts written in C. I went through its sources and looks like it heavily depends on underlying platform-specific ODBC drivers. I don't see an easy way to use that on a mobile device.

Architecturally, it would be more right having a backend service running on the server and a mobile app accessing that service via HTTP/sockets. Backend service in its turn uses ODBC to make low-level calls to the database and exposes high-level API to your mobile app. Also, your mobile app cannot contain database connection string details (or any other private/sensitive) as anyone can retrieve that data from the app package.

Hope that helps. So please advise me on a solution and knowledge so that mobile can connect to sql server and execute commands. Thank you

Heoder avatar Jan 10 '24 01:01 Heoder

OK, guys, the problem is in pyodbc module which is non-pure Python module with parts written in C. I went through its sources and looks like it heavily depends on underlying platform-specific ODBC drivers. I don't see an easy way to use that on a mobile device. Architecturally, it would be more right having a backend service running on the server and a mobile app accessing that service via HTTP/sockets. Backend service in its turn uses ODBC to make low-level calls to the database and exposes high-level API to your mobile app. Also, your mobile app cannot contain database connection string details (or any other private/sensitive) as anyone can retrieve that data from the app package. Hope that helps. So please advise me on a solution and knowledge so that mobile can connect to sql server and execute commands. Thank you

Hey @akunzz , please do format your quote reply correctly. It's difficult to tell which one is your reply to another else's quote, because you make all the text, even your own reply into quote. Do remove that ">" brackets at the start of "your reply" lines in quote replies. Sorry if I appear rude. Hope you got it. Thank you

taaaf11 avatar Jan 10 '24 02:01 taaaf11

Thank you, I'm Vietnamese, I'm not afraid of github, now I've determined the cause is pyodbc, so is there any way to create a mobile application that can connect to sql server. Or can you advise me on whether or not I can decompress the client server api?

Heoder avatar Jan 10 '24 03:01 Heoder

so is there any way to create a mobile application that can connect to sql server. Or can you advise me on whether or not I can decompress the client server api?

I am afraid to answer your comment, because I am not much into database things...

taaaf11 avatar Jan 10 '24 03:01 taaaf11

Like I noted earlier, create a backend service and access it from Flet app (hence device) via HTTP. Backend service could be anything from a simple FastAPI or Flask to Firebase, Supabase (docs), Pocketbase or other *base.

FeodorFitsner avatar Jan 11 '24 03:01 FeodorFitsner