Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flet build aab process failed with dart error #4676

Open
1 task done
JunDamin opened this issue Jan 9, 2025 · 1 comment
Open
1 task done

flet build aab process failed with dart error #4676

JunDamin opened this issue Jan 9, 2025 · 1 comment

Comments

@JunDamin
Copy link

JunDamin commented Jan 9, 2025

Duplicate Check

Describe the bug

It worked but after I update flet and android studio, it starts to fail.

I use version below.
flet == 0.25.2
adriod studio == 2024.2.1
flutter == 3.27.1

When I build a bundle a package, I faced error below.
It has no error when I flet run.
How can I solve the problem?


(flet-test-py3.10) C:\Users\freed\Documents\python_projects\flet-test>flet build aab
[15:32:38] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.25.2 :white_check_mark:
Customized app icons and splash images ✅
[15:32:48] Generated app icons :white_check_mark:
[15:32:52] Generated splash screens :white_check_mark:
[15:34:09] Packaged Python app :white_check_mark:
[15:35:11]
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... 57.9s

       ../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/flet-0.25.2/lib/src/utils/theme.dart:356:28: Error: A value of type 'TabBarThemeData' can't be returned from a function with return type 'TabBarTheme?'. 
        - 'TabBarThemeData' is from 'package:flutter/src/material/tab_bar_theme.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/material/tab_bar_theme.dart').
        - 'TabBarTheme' is from 'package:flutter/src/material/tab_bar_theme.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/material/tab_bar_theme.dart').
         return theme.tabBarTheme.copyWith(
                                  ^
       ../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/flet-0.25.2/lib/src/utils/theme.dart:438:28: Error: A value of type 'DialogThemeData' can't be returned from a function with return type 'DialogTheme?'. 
        - 'DialogThemeData' is from 'package:flutter/src/material/dialog_theme.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/material/dialog_theme.dart').
        - 'DialogTheme' is from 'package:flutter/src/material/dialog_theme.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/material/dialog_theme.dart').
         return theme.dialogTheme.copyWith(
                                  ^
       ../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/flet-0.25.2/lib/src/utils/theme.dart:482:26: Error: A value of type 'CardThemeData' can't be returned from a function with return type 'CardTheme?'.     
        - 'CardThemeData' is from 'package:flutter/src/material/card_theme.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/material/card_theme.dart').
        - 'CardTheme' is from 'package:flutter/src/material/card_theme.dart' ('../../../../flutterSDK/flutter/packages/flutter/lib/src/material/card_theme.dart').
         return theme.cardTheme.copyWith(
                                ^
       Target kernel_snapshot_program failed: Exception


       FAILURE: Build failed with an exception.

       * What went wrong:
       Execution failed for task ':app:compileFlutterBuildRelease'.

Process 'command 'C:\Users\freed\Documents\flutterSDK\flutter\bin\flutter.bat'' finished with non-zero exit value 1

       * 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.

       BUILD FAILED in 56s
       Gradle task bundleRelease failed with exit code 1

       Error building Flet app - see the log of failed command above.

[15:35:20] Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.22631.4602], locale ko-KR)
[√] 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.6.4)
[√] Android Studio (version 2024.2)
[√] VS Code (version 1.96.2)
[√] Connected device (3 available)
[√] Network resources

       • No issues found!

Code sample

Code

it is the todo app code from gallery

import flet as ft


class Task(ft.Column):
    def __init__(self, task_name, task_status_change, task_delete):
        super().__init__()
        self.completed = False
        self.task_name = task_name
        self.task_status_change = task_status_change
        self.task_delete = task_delete
        self.display_task = ft.Checkbox(
            value=False, label=self.task_name, on_change=self.status_changed
        )
        self.edit_name = ft.TextField(expand=1)

        self.display_view = ft.Row(
            alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
            vertical_alignment=ft.CrossAxisAlignment.CENTER,
            controls=[
                self.display_task,
                ft.Row(
                    spacing=0,
                    controls=[
                        ft.IconButton(
                            icon=ft.icons.CREATE_OUTLINED,
                            tooltip="Edit To-Do",
                            on_click=self.edit_clicked,
                        ),
                        ft.IconButton(
                            ft.icons.DELETE_OUTLINE,
                            tooltip="Delete To-Do",
                            on_click=self.delete_clicked,
                        ),
                    ],
                ),
            ],
        )

        self.edit_view = ft.Row(
            visible=False,
            alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
            vertical_alignment=ft.CrossAxisAlignment.CENTER,
            controls=[
                self.edit_name,
                ft.IconButton(
                    icon=ft.icons.DONE_OUTLINE_OUTLINED,
                    icon_color=ft.colors.GREEN,
                    tooltip="Update To-Do",
                    on_click=self.save_clicked,
                ),
            ],
        )
        self.controls = [self.display_view, self.edit_view]

    def edit_clicked(self, e):
        self.edit_name.value = self.display_task.label
        self.display_view.visible = False
        self.edit_view.visible = True
        self.update()

    def save_clicked(self, e):
        self.display_task.label = self.edit_name.value
        self.display_view.visible = True
        self.edit_view.visible = False
        self.update()

    def status_changed(self, e):
        self.completed = self.display_task.value
        self.task_status_change(self)

    def delete_clicked(self, e):
        self.task_delete(self)


class TodoApp(ft.Column):
    # application's root control is a Column containing all other controls
    def __init__(self):
        super().__init__()
        self.new_task = ft.TextField(
            hint_text="What needs to be done?", on_submit=self.add_clicked, expand=True
        )
        self.tasks = ft.Column()

        self.filter = ft.Tabs(
            scrollable=False,
            selected_index=0,
            on_change=self.tabs_changed,
            tabs=[ft.Tab(text="all"), ft.Tab(text="active"), ft.Tab(text="completed")],
        )

        self.items_left = ft.Text("0 items left")

        self.width = 600
        self.controls = [
            ft.Row(
                [ft.Text(value="Todos", theme_style=ft.TextThemeStyle.HEADLINE_MEDIUM)],
                alignment=ft.MainAxisAlignment.CENTER,
            ),
            ft.Row(
                controls=[
                    self.new_task,
                    ft.FloatingActionButton(
                        icon=ft.icons.ADD, on_click=self.add_clicked
                    ),
                ],
            ),
            ft.Column(
                spacing=25,
                controls=[
                    self.filter,
                    self.tasks,
                    ft.Row(
                        alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
                        vertical_alignment=ft.CrossAxisAlignment.CENTER,
                        controls=[
                            self.items_left,
                            ft.OutlinedButton(
                                text="Clear completed", on_click=self.clear_clicked
                            ),
                        ],
                    ),
                ],
            ),
        ]

    def add_clicked(self, e):
        if self.new_task.value:
            task = Task(self.new_task.value, self.task_status_change, self.task_delete)
            self.tasks.controls.append(task)
            self.new_task.value = ""
            self.new_task.focus()
            self.update()

    def task_status_change(self, task):
        self.update()

    def task_delete(self, task):
        self.tasks.controls.remove(task)
        self.update()

    def tabs_changed(self, e):
        self.update()

    def clear_clicked(self, e):
        for task in self.tasks.controls[:]:
            if task.completed:
                self.task_delete(task)

    def before_update(self):
        status = self.filter.tabs[self.filter.selected_index].text
        count = 0
        for task in self.tasks.controls:
            task.visible = (
                status == "all"
                or (status == "active" and task.completed == False)
                or (status == "completed" and task.completed)
            )
            if not task.completed:
                count += 1
        self.items_left.value = f"{count} active item(s) left"


def main(page: ft.Page):
    page.title = "ToDo App"
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.scroll = ft.ScrollMode.ADAPTIVE

    # create app control and add it to the page
    page.add(TodoApp())


ft.app(main)```

</details>


### To reproduce

you can reproduce it when you run `flet build aab`

### Expected behavior

_No response_

### Screenshots / Videos

<details open>
<summary>Captures</summary>

[Upload media here]

</details>


### Operating System

Windows

### Operating system details

windows 11

### Flet version

0.25.2

### Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

### Suggestions

_No response_

### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]

Additional details

No response

@LilMaxonthebeat
Copy link

LilMaxonthebeat commented Jan 9, 2025

Had same error when building and for me downgrading a bit worked well, there is need to adopt some changes from flutter sdk in flet,my current versions below

Flet version

flet --version
0.25.0

Flutter version

flutter --version
Flutter 3.24.5 • channel [user-branch] • unknown source
Framework • revision dec2ee5c1f (8 weeks ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3

So you can try to simply downgrade both flet and flutter to stable versions in which they work good like shown below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants