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.34k stars 442 forks source link

Error building Flet app - see the log of failed command above. | Issue I can't identify #3652

Open jack-tol opened 3 months ago

jack-tol commented 3 months ago

Duplicate Check

Describe the bug

Any help would be appreciated. No matter how precisely I follow the guides to create my environments or clean slate everything (even tried various versions of Python), when I build my Flet application for iOS (using kivy-ios), I keep getting this same error.

Followed Documentation Here:

Environment Specifications

The terminal command which I'm experiencing the issues with: flet build ipa.

Code sample

Just running this command for my application (main.py) flet build ipa makes it not build properly. I'm using kivy-ios to build the python environment.

To reproduce

I've tried flutter doctor, actually changing the code in the files it tells me to, removing the files, running flake8 to identify issues with the code, but nothing... nothing solves it.

Tried toolchain distclean, clearing .cache file, new virtual environments.

I'm making sure to:

And then... that error... every damn time.

Expected behavior

The Xcode project to be built, such that I can publish it to my phone and test.

Screenshots / Videos

Screenshot 2024-07-17 at 02 16 54

Operating System

macOS

Operating system details

macOS Sonoma 14.5 (23F79)

Flet version

Version: 0.23.2

Regression

No, it isn't

Suggestions

No response

Logs

Logs ```console (myvenv) jack@192-168-68-114 faster-landoff % flet build ipa --verbose /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/watchdog/observers/__init__.py:78: UserWarning: Failed to import fsevents. Fall back to kqueue warnings.warn("Failed to import fsevents. Fall back to kqueue") [02:26:32] Flutter bootstrap directory: /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/flet_flutter_build_lBjXmsZ9L0 Additional Flutter dependencies: {} [02:26:34] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅ Customized app icons and splash images ✅ Run subprocess: ['/opt/homebrew/bin/dart', 'run', 'flutter_launcher_icons'] ( ● ) Generating app icons (3.3s) Downloading packages... ( ● ) Generating app icons ⏳... Got dependencies in `/private/var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/flet_flutter_build_lBjXmsZ9L0`. ( ● ) Generating app icons ⏳... Built flutter_launcher_icons:flutter_launcher_icons. ( ● ) Generating app icons ⏳... ════════════════════════════════════════════ FLUTTER LAUNCHER ICONS (v0.13.1) ════════════════════════════════════════════ • Creating default icons Android ( ● ) Generating app icons ⏳... • Overwriting the default Android launcher icon with a new icon ( ● ) Generating app icons ⏳... • Overwriting default iOS launcher icon with new icon ( ● ) Generating app icons ⏳...done ( ● ) Generating app icons ⏳...done ( ● ) Generating app icons ⏳...done ✓ Successfully generated launcher icons [02:26:40] Generated app icons ✅ Run subprocess: ['/opt/homebrew/bin/dart', 'run', 'flutter_native_splash:create'] ( ● ) Generating splash screens ⏳... Built flutter_native_splash:create. ( ● ) Generating splash screens ⏳... [Android] Creating default splash images (● ) Generating splash screens ⏳... [Android] Creating dark mode splash images ( ● ) Generating splash screens ⏳... [Android] Creating default android12splash images ( ● ) Generating splash screens ⏳... [Android] Creating dark mode android12splash images ( ● ) Generating splash screens ⏳... [Android] Updating launch background(s) with splash image path... [Android] - android/app/src/main/res/drawable/launch_background.xml ( ●) Generating splash screens ⏳... [Android] - android/app/src/main/res/drawable-night/launch_background.xml [Android] - android/app/src/main/res/drawable-v21/launch_background.xml [Android] - android/app/src/main/res/drawable-night-v21/launch_background.xml [Android] Updating styles... [Android] - android/app/src/main/res/values-v31/styles.xml [Android] No android/app/src/main/res/values-v31/styles.xml found in your Android project [Android] Creating android/app/src/main/res/values-v31/styles.xml and adding it to your Android project [Android] - android/app/src/main/res/values-night-v31/styles.xml [Android] No android/app/src/main/res/values-night-v31/styles.xml found in your Android project [Android] Creating android/app/src/main/res/values-night-v31/styles.xml and adding it to your Android project [Android] - android/app/src/main/res/values/styles.xml [Android] - android/app/src/main/res/values-night/styles.xml [iOS] Creating images ( ● ) Generating splash screens ⏳... [iOS] Creating dark mode images ( ● ) Generating splash screens ⏳... [iOS] Updating ios/Runner/Info.plist for status bar hidden/visible [Web] Creating images ( ● ) Generating splash screens ⏳... [Web] Creating images ( ● ) Generating splash screens ⏳... [Web] Creating background images [Web] Creating CSS [Web] Updating index.html ✅ Native splash complete. Now go finish building something awesome! 💪 You rock! 🤘🤩 Like the package? Please give it a 👍 here: https://pub.dev/packages/flutter_native_splash [02:26:42] Generated splash screens ✅ Run subprocess: ['/opt/homebrew/bin/dart', 'run', 'serious_python:main', 'package', '/Users/jack/Desktop/faster-landoff', '--mobile', '--platform', 'mobile', '--dep-mappings', 'flet=flet-embed', '--req-deps', 'flet-embed', '--exclude', 'build'] ( ● ) Packaging Python app ⏳... Built serious_python:main. ( ● ) Packaging Python app ⏳... Running package command Creating asset directory: /private/var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/flet_flutter_build_lBjXmsZ9L0/app Copying Python app from /Users/jack/Desktop/faster-landoff to /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_tempxDfRvc (● ) Packaging Python app ⏳... Configured mobile platform with sitecustomize.py at /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_sitecustomizeJEsaA5/sitecustomize.py Installing dependencies [flet-embed] with pip command to /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_tempxDfRvc/__pypackages__ Extracting Python distributive from /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/cpython-3.11.6+20231002-aarch64-apple-darwin-install_only.tar.gz to /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/hostpython3.11_7itb4z ( ● ) Packaging Python app ⏳... Compiling Python sources at /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_tempxDfRvc ( ● ) Packaging Python app ⏳... /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_tempxDfRvc/dist/hostpython3/lib/python3.11/lib2to3/tests/data/py3_test_grammar.py:664: SyntaxWarning: "is" with a literal. Did you mean "=="? if 1 is 1: pass /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_tempxDfRvc/dist/hostpython3/lib/python3.11/lib2to3/tests/data/py3_test_grammar.py:665: SyntaxWarning: "is not" with a literal. Did you mean "!="? if 1 is not 1: pass /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/serious_python_tempxDfRvc/dist/hostpython3/lib/python3.11/lib2to3/tests/data/py3_test_grammar.py:668: SyntaxWarning: "is" with a literal. Did you mean "=="? if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass [02:27:02] Deleting Flutter bootstrap directory /var/folders/hw/cf_hj45n5z74gxf0yc0y4jdc0000gn/T/flet_flutter_build_lBjXmsZ9L0 Error building Flet app - see the log of failed command above. ```

Additional details

No response

wpritom commented 3 months ago

I'm facing the same issue in Windows 11. Flet version 0.23.2

Here is the log from --verbose command.

PS D:\PROJECT\watchdog> flet build windows --module-name app.py --verbose
[18:31:41] Flutter bootstrap directory: C:\Users\Home~1\AppData\Local\Temp\flet_flutter_build_alxwjmNHiK
           Additional Flutter dependencies:
           {}
[18:31:44] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅
           Customized app icons and splash images ✅
           Run subprocess: ['C:\\Users\\homepc\\AppData\\Local\\dev\\flutter\\flutter\\bin\\dart.BAT', 'run',
           'flutter_launcher_icons']
(    ● ) Generating app icons ⏳... Resolving dependencies in `C:\Users\Home~1\AppData\Local\Temp\flet_flutter_build_a(     ●) Generating app icons (1.6s)
Downloading packages...
Got dependencies in `C:\Users\Home~1\AppData\Local\Temp\flet_flutter_build_alxwjmNHiK`.
(●     ) Generating app icons (1.2s)
Built flutter_launcher_icons:flutter_launcher_icons.
(    ● ) Generating app icons ⏳...   ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.13.1)
  ════════════════════════════════════════════

(     ●) Generating app icons ⏳... • Creating default icons Android
(    ● ) Generating app icons ⏳... • Overwriting the default Android launcher icon with a new icon
(  ●   ) Generating app icons ⏳... • Overwriting default iOS launcher icon with new icon
(    ● ) Generating app icons ⏳... Creating Icons for Web...
(   ●  ) Generating app icons ⏳... Creating Icons for Windows...
(  ●   ) Generating app icons ⏳... Creating Icons for MacOS...
(  ●   ) Generating app icons ⏳...
✓ Successfully generated launcher icons
[18:31:49] Generated app icons ✅
           Run subprocess: ['C:\\Users\\homepc\\AppData\\Local\\dev\\flutter\\flutter\\bin\\dart.BAT', 'run',
           'serious_python:main', 'package', 'D:\\PROJECT\\watchdog', '--dep-mappings', 'flet=flet-embed',
           '--req-deps', 'flet-embed', '--exclude', 'build']
(   ●  ) Packaging Python app ⏳...
Built serious_python:main.
(  ●   ) Packaging Python app ⏳... Running package command
Creating asset directory: C:\Users\Home~1\AppData\Local\Temp\flet_flutter_build_alxwjmNHiK\app
Copying Python app from D:\PROJECT\watchdog to C:\Users\Home~1\AppData\Local\Temp\serious_python_temp9e214876
( ●    ) Packaging Python app ⏳... Installing dependencies [APScheduler==3.10.4, flet-embed==0.23.2, pymongo==4.8.0, Windows_Toasts==1.2.0] with pip command to C:\Users\Home~1\AppData\Local\Temp\serious_python_temp9e214876\__pypackages__Extracting Python distributive from C:\Users\Home~1\AppData\Local\Temp\cpython-3.11.6+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz to C:\Users\Home~1\AppData\Local\Temp\hostpython3.11_cd04f58
(     ●) Packaging Python app ⏳... Compiling Python sources at C:\Users\Home~1\AppData\Local\Temp\serious_python_temp9e214876
[18:32:09] Deleting Flutter bootstrap directory C:\Users\Home~1\AppData\Local\Temp\flet_flutter_build_alxwjmNHiK
           Error building Flet app - see the log of failed command above.

requirements.txt contains the following:

APScheduler==3.10.4
flet==0.23.2
pymongo==4.8.0
Windows_Toasts==1.2.0
wpritom commented 3 months ago

@jack-tol , can you try with -vv instead of --verbose. It showed better log at my side. I've solved the issue already.

abhimobi commented 3 days ago

I have the same issue on macOS.

Command I ran: flet build macos --module-name dashboard.py -vv

Logs

Compiling '/var/folders/yw/6x6llpl160dbzsx828k3zmqw0000gq/T/serious_python_tempCdF4Vi/cell_temperature_chart.py'...
Compiling '/var/folders/yw/6x6llpl160dbzsx828k3zmqw0000gq/T/serious_python_tempCdF4Vi/cell_voltage_chart.py'...
Compiling '/var/folders/yw/6x6llpl160dbzsx828k3zmqw0000gq/T/serious_python_tempCdF4Vi/dashboard.py'...
Compiling '/var/folders/yw/6x6llpl160dbzsx828k3zmqw0000gq/T/serious_python_tempCdF4Vi/dhw_ui.py'...
[15:08:08] Deleting Flutter bootstrap directory /var/folders/yw/6x6llpl160dbzsx828k3zmqw0000gq/T/flet_flutter_build_nuyp2Fg9lX                                                                                     
           Error building Flet app - see the log of failed command above.                                                                                                                                          
           Run subprocess: ['/Users/abhimittal/development/flutter/bin/flutter', 'doctor']                                                                                                                         
[15:08:17] Doctor summary (to see all details, run flutter doctor -v):                                                                                                                                             
           [✓] Flutter (Channel stable, 3.24.4, on macOS 15.0.1 24A348 darwin-arm64, locale en-GB)                                                                                                                 
           [✗] Android toolchain - develop for Android devices                                                                                                                                                     
               ✗ Unable to locate Android SDK.                                                                                                                                                                     
                 Install Android Studio from: https://developer.android.com/studio/index.html                                                                                                                      
                 On first launch it will assist you in installing the Android SDK components.                                                                                                                      
                 (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).                                                                                                                  
                 If the Android SDK has been installed to a custom location, please use                                                                                                                            
                 `flutter config --android-sdk` to update to that location.                                                                                                                                        

           [✓] Xcode - develop for iOS and macOS (Xcode 16.1)                                                                                                                                                      
           [✓] Chrome - develop for the web                                                                                                                                                                        
           [!] Android Studio (not installed)                                                                                                                                                                      
           [✓] VS Code (version 1.94.2)

requirements.txt contains:

flet==0.24.1
paho-mqtt==2.1.0
FeodorFitsner commented 3 days ago

@abhimobi install Android Studio which will install Android SDK

FeodorFitsner commented 3 days ago

@abhimobi scratch it - I haven't noticed you were building for macOS. Try building the app with pre-release version of Flet.

abhimobi commented 3 days ago

@FeodorFitsner - thank you, this helped (kind of). My app now builds and I get a bundle. However, when I run the App it just loads a blank window, with no controls or other errors. I will investigate this separately.

ap4499 commented 3 days ago

@abhimobi - using logging. In the latest build (I'm on 0.25.0dev3646/7), there is a log that you will find in the application's cache.

    import logging
    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger("flet_core").setLevel(logging.DEBUG)
    logging.getLogger("flet").setLevel(logging.DEBUG)

For something built with the following args: flet build macos --project "Demo" --product "Demo" --org "com.ABC" --company "Demo" --build-version "1.0.0" -vv You'll find it in: /Users/[USER]/Library/Caches/com.ABC.demo/console.log

In my own application, I found it was often my imports that were causing the issue that you are describing, and so I wrapped them like this (I used a custom logger, but I think this is the syntax needed):

import logging
logging.basicConfig(level=logging.DEBUG)

# Get a logger for your current module
logger = logging.getLogger(__name__)

logger.debug("About to import pandas")
try:
    import pandas as pd

except ImportError as e:
    logger.error(f"Import failed: {e}")

That led me to discovering which ones were breaking, and then I could debug from there.

edit* link to the Flet Logging documentation I used for the above: https://flet.dev/docs/cookbook/logging/

abhimobi commented 1 hour ago

Thanks @ap4499. My cache folder (/Users/abhimittal/Library/Caches/com.ABC.demo) remains an empty directory after the App is launched. I have followed your logging example above. I will continue researching and/or try with newer releases.