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

Error: flet Build apk failed in flet 0.25.2 #4615

Closed
1 task done
imadityacoder opened this issue Dec 23, 2024 · 8 comments
Closed
1 task done

Error: flet Build apk failed in flet 0.25.2 #4615

imadityacoder opened this issue Dec 23, 2024 · 8 comments

Comments

@imadityacoder
Copy link

Duplicate Check

Describe the bug

After running flet build apk it give some unknown error which is "A value of type 'TabBarThemeData' can't be returned from a function with return type 'TabBarTheme?'".

Code sample

Code
from flet import *
from time import sleep


def main(page:Page):
    page.vertical_alignment = "top"
    page.horizontal_alignment = "center"
    page.window.height = 720
    page.window.width = 420
    page.theme_mode=ThemeMode.DARK
    page.padding = Padding(top=30,bottom=6,right=6,left=6)


    def openbn():
        page.banner.open=True
        page.update()

    banner=Banner(  
        bgcolor=Colors.AMBER_100,
        leading=Icon(Icons.WARNING_AMBER_ROUNDED, color=Colors.AMBER, size=40),
        content=Text("This is now in updating!!!",color=Colors.BLACK54),
        actions=[IconButton(Icons.LABEL_IMPORTANT_ROUNDED)]
        )
    page.overlay.append(banner)

    def theme(e):
        if page.theme_mode == ThemeMode.DARK:
            page.theme_mode=ThemeMode.LIGHT
            page.bgcolor= Colors.LIGHT_GREEN_100
            page.update()
        else:
            page.theme_mode=ThemeMode.DARK
            page.bgcolor=Colors.BLACK12
            page.update()
            
    def profile(e):
        openbn()
        sleep(5)
        page.banner.open=False
        page.update()

    page.appbar=AppBar(
        leading=Icon(Icons.DEVICE_THERMOSTAT_SHARP),
        leading_width=40,
        title=Text("Aditya's Temprature Converter",size=16),
        center_title=False,
        bgcolor=Colors.OUTLINE_VARIANT,
        actions=[
            IconButton(
                Icons.LIGHT_MODE_OUTLINED,
                on_click=lambda e:theme(e),
                tooltip="Theme Mode"
                ),
            IconButton(
                Icons.SETTINGS_SHARP,
                on_click= lambda e:profile(e)
                ),
        ],
    )

    boxw = 260
    fsize = 26

    d1 = Dropdown(
            width=boxw,
            value="Celcius",
            options=[
                dropdown.Option("Celcius"),
                dropdown.Option("Farenheit"),
                dropdown.Option("Kelvin"),
            ],
        )
    
    
    d2=Dropdown(
            width=boxw,
            value="Farenheit",
            options=[
                dropdown.Option("Celcius"),
                dropdown.Option("Farenheit"),
                dropdown.Option("Kelvin"),
            ], 
            
            )
    
    box1= TextField(
        text_align="center",
        text_size= fsize,
        border_radius= 10,
        autofocus= True,
        on_change=lambda e:mainfunc(e),
        bgcolor=Colors.GREEN_600,
        width=boxw,
        keyboard_type=KeyboardType.NUMBER,
        max_length=12,
        
        )

    box2= TextField(
        text_align="center",
        text_size= fsize,
        border_radius= 8,
        bgcolor=Colors.BLUE_ACCENT_400,
        width=boxw,
        read_only=True,
        adaptive=True,
        max_length=18,
        
    )

    def mainfunc(e):
        inp1=box1.value

        try:
            if d1.value ==  d2.value:
                box2.value=int(inp1)
                page.update()

            elif box1.value == "":
                box2.value= ""
                page.update()
    
            elif d1.value =="Celcius" and d2.value == "Farenheit":
                
                box2.value=str((float(inp1)*9/5)+32)
                page.update()

            elif d1.value =="Celcius" and d2.value == "Kelvin":
                box2.value=str(float(inp1)+273.15)
                page.update()

            elif d1.value =="Farenheit" and d2.value == "Kelvin":
                box2.value=str(((float(inp1)-32)*5/9+273.15)//1)
                page.update()

            elif d1.value =="Farenheit" and d2.value == "Celcius":
                box2.value=str(((float(inp1)-32)*5/9)//1)
                page.update()

            elif d1.value =="Kelvin" and d2.value == "Celcius":
                box2.value=str(float(inp1)-273.15)
                page.update()
                
            elif d1.value =="Kelvin" and d2.value == "Farenheit":
                box2.value=str(((float(inp1)-273.15)*9/5+32)//1)
                page.update()

        except Exception:
            pass


    page.add(
        
        ResponsiveRow(
            controls=[
                d1,
                box1,
            ],
        ),
        ResponsiveRow(
            controls=[
                d2,
                box2,
            ],
           
        ),

    )
    page.update()

app(target=main)

To reproduce

Steps to reproduce:

step 1:
Save the given code in main.py file.

step 2:
On windows: pip install flet
On linux or mac: pip3 install flet

step 3:
Open terminal/powershell in in the directory of given code file.

step 4:
Run: flet build apk

Expected behavior

I expected that after running 'flet build apk' it convert my python app into apk file.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Linux

Operating system details

Ubuntu 23.04.1LTS

Flet version

flet-0.25.2

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
aditya@adi-system:~/code playground/FletCode/temperature-convertor-main$ flet build apk
[16:30:46] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref
           0.25.2 ✅                                                                      
           Customized app icons and splash images ✅                                      
[16:31:25] Generated app icons ✅                                                         
[16:31:35] Generated splash screens ✅                                                    
[16:33:35] Packaged Python app ✅                                                         
[16:35:00]                                                                                
           Running Gradle task 'assembleRelease'...                                       
           Running Gradle task 'assembleRelease'...                           81.5s       
                                                                                          
           Warning: SDK processing. This version only understands SDK XML versions up to 3
           but an SDK XML file of version 4 was encountered. This can happen if you use   
           versions of Android Studio and the command-line tools that were released at    
           different times.                                                               
           ../../../../../.pub-cache/hosted/pub.dev/flet-0.25.2/lib/src/utils/theme.dart:3
           56: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' 
           ('../../../../../development/flutter/packages/flutter/lib/src/material/tab_bar_
           theme.dart').                                                                  
            - 'TabBarTheme' is from 'package:flutter/src/material/tab_bar_theme.dart'     
           ('../../../../../development/flutter/packages/flutter/lib/src/material/tab_bar_
           theme.dart').                                                                  
             return theme.tabBarTheme.copyWith(                                           
                                      ^                                                   
           ../../../../../.pub-cache/hosted/pub.dev/flet-0.25.2/lib/src/utils/theme.dart:4
           38: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'  
           ('../../../../../development/flutter/packages/flutter/lib/src/material/dialog_t
           heme.dart').                                                                   
            - 'DialogTheme' is from 'package:flutter/src/material/dialog_theme.dart'      
           ('../../../../../development/flutter/packages/flutter/lib/src/material/dialog_t
           heme.dart').                                                                   
             return theme.dialogTheme.copyWith(                                           
                                      ^                                                   
           ../../../../../.pub-cache/hosted/pub.dev/flet-0.25.2/lib/src/utils/theme.dart:4
           82: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'      
           ('../../../../../development/flutter/packages/flutter/lib/src/material/card_the
           me.dart').                                                                     
            - 'CardTheme' is from 'package:flutter/src/material/card_theme.dart'          
           ('../../../../../development/flutter/packages/flutter/lib/src/material/card_the
           me.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 '/home/aditya/development/flutter/bin/flutter'' 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 1m 20s                                                         
           Gradle task assembleRelease failed with exit code 1                            
                                                                                          
           Error building Flet app - see the log of failed command above.                 
[16:35:14] Doctor summary (to see all details, run flutter doctor -v):                    
           [✓] Flutter (Channel stable, 3.27.0, on Ubuntu 24.04.1 LTS 6.8.0-51-generic,   
           locale en_US.UTF-8)                                                            
           [✓] Android toolchain - develop for Android devices (Android SDK version       
           35.0.0)                                                                        
           [✓] Chrome - develop for the web                                               
           [✓] Linux toolchain - develop for Linux desktop                                
           [✓] Android Studio (version 2024.1)                                            
           [✓] VS Code (version 1.96.1)                                                   
           [✓] Connected device (2 available)                                             
           [✓] Network resources                                                          
                                                                                          
           • No issues found!            

Additional details

No response

@youssef969
Copy link

+1

@Muddassir-Farooq-official
Copy link

Muddassir-Farooq-official commented Dec 23, 2024

Share your requirements.txt

@imadityacoder
Copy link
Author

Share your requirements.txt

requirements.txt

@youssef969
Copy link

Share your requirements.txt

requirements.txt

what is your Flutter version ?

@pnkmem429
Copy link

I don't know whether it works, but try downgrading Flutter SDK into 3.24.5 or below.

@stephen-lspd
Copy link

Can confirm that my builds were also erroring out and downgrading to Flutter SDK 3.24.5 worked.
Thanks for the tip @pnkmem429 !

@imadityacoder
Copy link
Author

I don't know whether it works, but try downgrading Flutter SDK into 3.24.5 or below.

I will try it.

@ndonkoHenri
Copy link
Contributor

If you want to use Flutter 3.27, follow this: #4548 (comment)

@flet-dev flet-dev locked and limited conversation to collaborators Dec 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants