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
10.85k stars 417 forks source link

Error on windows10 apk build from demo app ( Deletion failed, OS Error: Access is denied. ) #3848

Open Buggist opened 3 weeks ago

Buggist commented 3 weeks ago

Duplicate Check

Describe the bug

Just trying to build the demo app created by command "flet create . " to apk, and it was failed.

Code sample

Code ```python import flet as ft def main(page: ft.Page): page.add(ft.SafeArea(ft.Text("Hello, Flet!"))) ft.app(main) ```

To reproduce

(312-flet023-test) C:\Users\kg\Desktop\fletty>flet build apk --verbose

[10:20:51] Flutter bootstrap directory: C:\Users\kg\AppData\Local\Temp\flet_flutter_build_bEl3t76syP Additional Flutter dependencies: {} [10:20:54] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅ Copying C:\Users\kg\Desktop\fletty\assets\icon.ico to C:\Users\kg\AppData\Local\Temp\flet_flutter_build_bEl3t76syP\images Customized app icons and splash images ✅ Run subprocess: ['C:\Programming\flutter\bin\dart.BAT', 'run', 'flutter_launcher_icons'] ( ● ) Generating app icons ⏳... Resolving dependencies in C:\Users\kg\AppData\Local\Temp\flet_flutter_build_bEl3t7( ● ) Generating app icons (4.5s) Downloading packages... ( ● ) Generating app icons ⏳... Got dependencies inC:\Users\kg\AppData\Local\Temp\flet_flutter_build_bEl3t76syP`. ( ● ) Generating app icons ⏳... Built flutter_launcher_icons:flutter_launcher_icons. ( ● ) Generating app icons ⏳... ════════════════════════════════════════════ FLUTTER LAUNCHER ICONS (v0.13.1) ════════════════════════════════════════════

( ● ) Generating app icons ⏳... • Creating default icons Android • 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 [10:21:07] Generated app icons ✅ Run subprocess: ['C:\Programming\flutter\bin\dart.BAT', '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 [Android] Creating default android12splash images [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 [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 ( ● ) Generating splash screens ⏳... [Android] - android/app/src/main/res/values/styles.xml [Android] - android/app/src/main/res/values-night/styles.xml [iOS] Creating images [iOS] Creating dark mode images [iOS] Updating ios/Runner/Info.plist for status bar hidden/visible [Web] Creating images [Web] Creating images [Web] Creating background images [Web] Creating CSS ( ● ) Generating splash screens ⏳... [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

[10:21:10] Generated splash screens ✅ Run subprocess: ['C:\Programming\flutter\bin\dart.BAT', 'run', 'serious_python:main', 'package', 'C:\Users\kg\Desktop\fletty', '--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: C:\Users\kg\AppData\Local\Temp\flet_flutter_build_bEl3t76syP\app Copying Python app from C:\Users\kg\Desktop\fletty to C:\Users\kg\AppData\Local\Temp\serious_python_tempb5b5b217 ( ●) Packaging Python app ⏳... Configured mobile platform with sitecustomize.py at C:\Users\kg\AppData\Local\Temp\serious_python_sitecustomizedf99ffbe\sitecustomize.py Installing dependencies [flet-embed==0.22.*] with pip command to C:\Users\kg\AppData\Local\Temp\serious_python_tempb5b5b217__pypackages__ Extracting Python distributive from C:\Users\kg\AppData\Local\Temp\cpython-3.11.6+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz to C:\Users\kg\AppData\Local\Temp\hostpython3.11_4586fc97 ( ● ) Packaging Python app ⏳... Compiling Python sources at C:\Users\kg\AppData\Local\Temp\serious_python_tempb5b5b217 ( ● ) Packaging Python app ⏳... Error: FormatException: Unexpected extension byte (at offset 3147) Deleting temp directory C:\Users\kg\AppData\Local\Temp\serious_python_tempb5b5b217 ( ● ) Packaging Python app ⏳... Deleting sitecustomize directory C:\Users\kg\AppData\Local\Temp\serious_python_sitecustomizedf99ffbe Deleting Python directory C:\Users\kg\AppData\Local\Temp\hostpython3.11_4586fc97 Unhandled exception: PathAccessException: Deletion failed, path = 'C:\Users\kg\AppData\Local\Temp\hostpython3.11_4586fc97' (OS Error: Access is denied. , errno = 5)

0 _checkForErrorResponse (dart:io/common.dart:55:9)

1 _Directory._delete. (dart:io/directory_impl.dart:180:7)

#2 PackageCommand.run (file:///C:/Users/kg/AppData/Local/Pub/Cache/hosted/pub.dev/serious_python-0.7.1/bin/package_command.dart:363:9) #3 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #4 main (file:///C:/Users/kg/AppData/Local/Pub/Cache/hosted/pub.dev/serious_python-0.7.1/bin/main.dart:10:3) [10:21:28] Deleting Flutter bootstrap directory C:\Users\kg\AppData\Local\Temp\flet_flutter_build_bEl3t76syP Error building Flet app - see the log of failed command above. ### Expected behavior The build process should be success. ### Screenshots / Videos
Captures [Upload media here]
![example](https://github.com/user-attachments/assets/5d7b829e-5fc4-453e-875c-abd91d308823) ### Operating System Windows ### Operating system details Windows 10 Pro Version 22H2 ### Flet version both happend in 0.23.2 and 0.22.1 with same issue ### Regression No, it isn't ### Suggestions Not a clue. ### Logs
Logs ```console [Paste your logs here] ```
### Additional details _No response_
ndonkoHenri commented 3 weeks ago

Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅ ..... Installing dependencies [flet-embed==0.22.*]

Can you share your requirements file and the output of flutter doctor?

Buggist commented 2 weeks ago

Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅ ..... Installing dependencies [flet-embed==0.22.*]

Can you share your requirements file and the output of flutter doctor?

requirements.txt

flet==0.22.*

Buggist commented 2 weeks ago

flutter doctor

C:\Users\kg\Desktop>flutter doctor

┌─────────────────────────────────────────────────────────┐ │ A new version of Flutter is available! │ │ │ │ To update to the latest version, run "flutter upgrade". │ └─────────────────────────────────────────────────────────┘ Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [版本 10.0.19045.4651], locale zh-CN) [√] Windows Version (Installed version of Windows is version 10 or higher) [!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) X cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5) [√] Android Studio (version 2024.1) [√] Connected device (3 available) [√] Network resources

! Doctor found issues in 1 category.

Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅ ..... Installing dependencies [flet-embed==0.22.*]

Can you share your requirements file and the output of flutter doctor?

flutter doctor

C:\Users\kg\Desktop>flutter doctor

┌─────────────────────────────────────────────────────────┐ │ A new version of Flutter is available! │ │ │ │ To update to the latest version, run "flutter upgrade". │ └─────────────────────────────────────────────────────────┘ Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [版本 10.0.19045.4651], locale zh-CN) [√] Windows Version (Installed version of Windows is version 10 or higher) [!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) X cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5) [√] Android Studio (version 2024.1) [√] Connected device (3 available) [√] Network resources

! Doctor found issues in 1 category.

Buggist commented 2 weeks ago

Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅ ..... Installing dependencies [flet-embed==0.22.*]

Can you share your requirements file and the output of flutter doctor?

Thank you for reply, now I already fixed all issues showed on flutter doctor, but it is no help with my condition of build error.

flutter doctor

C:\Users\kg\Desktop>flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.19045.4651], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5) [√] Android Studio (version 2024.1) [√] Connected device (3 available) [√] Network resources

• No issues found!

tanmay-bhatgare commented 2 weeks ago

@Buggist, I’ve noticed that the packaging process takes an unusually long time and displays the message, "Packaging Python files," when running flet build apk on a local machine. However, this issue does not occur when executed on a virtual machine. I recommend checking this discussion if you are still experiencing packaging errors.

ByteJoseph commented 1 week ago

@Buggist, I’ve noticed that the packaging process takes an unusually long time and displays the message, "Packaging Python files," when running flet build apk on a local machine. However, this issue does not occur when executed on a virtual machine. I recommend checking this discussion if you are still experiencing packaging errors.

I have same issue. How to use virtual machine ?

tanmay-bhatgare commented 1 week ago

@ByteJoseph in my previous reply I have mentioned a discussion see that, I have already told entire process step by step just follow it and you're good to go.

ByteJoseph commented 1 week ago

@ByteJoseph in my previous reply I have mentioned a discussion see that, I have already told entire process step by step just follow it and you're good to go.

Thanks

ByteJoseph commented 5 days ago

Have you turned on developer mode? My issue is solved. It takes about 15 to 20 minutes to build the APK on my Windows 10 computer

Buggist commented 5 days ago

Have you turned on developer mode? My issue is solved. It takes about 15 to 20 minutes to build the APK on my Windows 10 computer

Yes I have. I finally find out a work flow to deal with this building issue, but tortuous, and the building process is still not stable.