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.38k stars 446 forks source link

I can't get application output with flet #3807

Closed merttalha closed 2 months ago

merttalha commented 2 months ago

Duplicate Check

Describe the bug

PS C:\Python Flet\Zikirmatik> flet build apk [13:14:46] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅
Customized app icons and splash images ✅
[13:14:52] Generated app icons ✅
[13:14:57] Generated splash screens ✅
[13:15:17] Packaged Python app ✅
[13:15:22] Resolving dependencies... Downloading packages... collection 1.18.0 (1.19.0 available) fl_chart 0.65.0 (0.68.0 available) flutter_lints 2.0.3 (4.0.0 available) flutter_markdown 0.6.23 (0.7.3+1 available) http_parser 4.0.2 (4.1.0 available) js 0.6.7 (0.7.1 available) lints 2.1.1 (4.0.0 available) material_color_utilities 0.11.1 (0.12.0 available) ! package_info_plus 8.0.2 (overridden) sensors_plus 4.0.2 (6.0.1 available) sensors_plus_platform_interface 1.2.0 (2.0.0 available) toml 0.15.0 (0.16.0 available) url_strategy 0.2.0 (0.3.0 available) ! wakelock_plus 1.2.8 (overridden) web_socket_channel 2.4.0 (3.0.1 available) window_manager 0.3.9 (0.4.0 available) Got dependencies! 14 packages have newer versions incompatible with dependency constraints. Try flutter pub outdated for more information.

       Running Gradle task 'assembleRelease'...
       Running Gradle task 'assembleRelease'...                         1.821ms

       FAILURE: Build failed with an exception.

       * Where:
       Build file 'C:\Users\user\AppData\Local\Temp\flet_flutter_build_WZEISUJgVE\android\app\build.gradle' line: 2

       * What went wrong:
       An exception occurred applying plugin request
       > Failed to apply plugin 'com.android.internal.application'.
          > Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
             Your current JDK is located in C:\Program Files\Android\Android Studio4\jre
             You can try some of the following options:
              - changing the IDE settings.
              - changing the JAVA_HOME environment variable.
              - changing `org.gradle.java.home` in `gradle.properties`.

       * Try:
       > Run with --stacktrace option to get the stack trace.
       > Run with --info or --debug option to get more log output.
       > Run with --scan to get full insights.
       > Get more help at https://help.gradle.org.

       BU�LD FAILED in 1s
       Gradle task assembleRelease failed with exit code 1

[13:15:23] Error building Flet app - see the log of failed command above.

Code sample

Code ```python [Paste your code here] ```

To reproduce

PS C:\Python Flet\Zikirmatik> flet build apk [13:14:46] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.23.2 ✅
Customized app icons and splash images ✅
[13:14:52] Generated app icons ✅
[13:14:57] Generated splash screens ✅
[13:15:17] Packaged Python app ✅
[13:15:22] Resolving dependencies... Downloading packages... collection 1.18.0 (1.19.0 available) fl_chart 0.65.0 (0.68.0 available) flutter_lints 2.0.3 (4.0.0 available) flutter_markdown 0.6.23 (0.7.3+1 available) http_parser 4.0.2 (4.1.0 available) js 0.6.7 (0.7.1 available) lints 2.1.1 (4.0.0 available) material_color_utilities 0.11.1 (0.12.0 available) ! package_info_plus 8.0.2 (overridden) sensors_plus 4.0.2 (6.0.1 available) sensors_plus_platform_interface 1.2.0 (2.0.0 available) toml 0.15.0 (0.16.0 available) url_strategy 0.2.0 (0.3.0 available) ! wakelock_plus 1.2.8 (overridden) web_socket_channel 2.4.0 (3.0.1 available) window_manager 0.3.9 (0.4.0 available) Got dependencies! 14 packages have newer versions incompatible with dependency constraints. Try flutter pub outdated for more information.

       Running Gradle task 'assembleRelease'...
       Running Gradle task 'assembleRelease'...                         1.821ms

       FAILURE: Build failed with an exception.

       * Where:
       Build file 'C:\Users\user\AppData\Local\Temp\flet_flutter_build_WZEISUJgVE\android\app\build.gradle' line: 2

       * What went wrong:
       An exception occurred applying plugin request
       > Failed to apply plugin 'com.android.internal.application'.
          > Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
             Your current JDK is located in C:\Program Files\Android\Android Studio4\jre
             You can try some of the following options:
              - changing the IDE settings.
              - changing the JAVA_HOME environment variable.
              - changing `org.gradle.java.home` in `gradle.properties`.

       * Try:
       > Run with --stacktrace option to get the stack trace.
       > Run with --info or --debug option to get more log output.
       > Run with --scan to get full insights.
       > Get more help at https://help.gradle.org.

       BU�LD FAILED in 1s
       Gradle task assembleRelease failed with exit code 1

[13:15:23] Error building Flet app - see the log of failed command above.

Expected behavior

No response

Screenshots / Videos

Captures [Upload media here] ![image](https://github.com/user-attachments/assets/aaee3715-a01b-4f25-af55-870842ee0bf8) ![image](https://github.com/user-attachments/assets/3ba05e22-dda1-4b36-b004-b2c69d8f7272) ![image](https://github.com/user-attachments/assets/5c8f9d8e-c723-458b-b471-fe40888279fc)

Operating System

Windows

Operating system details

windows 10

Flet version

son

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs ```console [Paste your logs here] ```

Additional details

No response

KelebekSiyah commented 2 months ago

Same error I got pls help us o7

merttalha commented 2 months ago

Aynı hatayı ben de aldım lütfen bize yardım edin o7

did you solve the problem?

CandyCrimsie commented 2 months ago

is the file you want to make an apk called main.py? If the error is with an incompatible version of the dependency, have you tried rolling them back to an older version?

Personally, for some reason it gives me the following error, supposedly it cannot send some emoji to the console, I tried encoding and rolling back packages - nothing helped

[13:26:39] Created Flutter bootstrap project from                              
           gh:flet-dev/flet-build-template with ref 0.23.0[13:26:39] Created Flutter bootstrap project from                              
flet : Traceback (most recent call last):
строка:1 знак:1
+ flet build apk --flutter-build-args=--target-platform --flutter-build ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\flet\cli\commands\build.py", line 462, in handle
    console.log(
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 1941, in log
    with self:
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_rend
er
    term.write_styled(text, style)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position 1: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\scripts\flet.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\flet\cli\cli.py", line 88, in main
    args.handler(args)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\flet\cli\commands\build.py", line 335, in handle
    with console.status(
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\status.py", line 106, in __exit__
    self.stop()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\status.py", line 91, in stop
    self._live.stop()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\live.py", line 147, in stop
    with self.console:
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_rend
er
    term.write_styled(text, style)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position 1: character maps to <undefined>
           gh:flet-dev/flet-build-template with ref 0.23.0
merttalha commented 2 months ago

apk yapmak istediğiniz dosyanın adı main.py mi? Eğer hata bağımlılığın uyumsuz bir sürümüyle ilgiliyse, onları daha eski bir sürüme geri döndürmeyi denediniz mi?

Şahsen, bir sebepten dolayı bana şu hatayı veriyor, sözde konsola bazı emojiler gönderemiyor, paketleri kodlamayı ve geri almayı denedim - hiçbir şey işe yaramadı

[13:26:39] Created Flutter bootstrap project from                              
           gh:flet-dev/flet-build-template with ref 0.23.0[13:26:39] Created Flutter bootstrap project from                              
flet : Traceback (most recent call last):
строка:1 знак:1
+ flet build apk --flutter-build-args=--target-platform --flutter-build ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\flet\cli\commands\build.py", line 462, in handle
    console.log(
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 1941, in log
    with self:
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_rend
er
    term.write_styled(text, style)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position 1: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\scripts\flet.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\flet\cli\cli.py", line 88, in main
    args.handler(args)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\flet\cli\commands\build.py", line 335, in handle
    with console.status(
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\status.py", line 106, in __exit__
    self.stop()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\status.py", line 91, in stop
    self._live.stop()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\live.py", line 147, in stop
    with self.console:
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_rend
er
    term.write_styled(text, style)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\Users\User\Desktop\my_apk_for_android\myenv\Lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position 1: character maps to <undefined>
           gh:flet-dev/flet-build-template with ref 0.23.0

Yes, my file's name is main.py, but I don't know the solution to your problem and no one is interested.

ndonkoHenri commented 2 months ago
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position 1: character maps to <undefined>
           gh:flet-dev/flet-build-template with ref 0.23.0

Ah, this issue! :) You need a newly added argument named --no-rich-output (more info) So, your command will be like this: flet build apk --no-rich-output (plus your additional stuffs).

It is not yet available in the latest flet versions though, so you need to pin a recent prerelease in your requirements file, ex: flet==0.24.0.dev3274

By the way, I think when using git cli (instead of powershell) you won't face this issue though.