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-ads error when try to build app #4770

Open
1 task done
zox47 opened this issue Jan 25, 2025 · 6 comments
Open
1 task done

flet-ads error when try to build app #4770

zox47 opened this issue Jan 25, 2025 · 6 comments

Comments

@zox47
Copy link

zox47 commented Jan 25, 2025

Duplicate Check

Describe the bug

I encountered an error while trying to build my app with flet-ads. It seems like the version might be unsupported, causing a conflict

Code sample

import flet as ft
import flet.ads as ads

def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

id_interstitial = (
    "ca-app-pub-3940256099942544/1033173712"
    if page.platform == ft.PagePlatform.ANDROID
    else "ca-app-pub-3940256099942544/4411468910"
)

id_banner = (
    "ca-app-pub-3940256099942544/6300978111"
    if page.platform == ft.PagePlatform.ANDROID
    else "ca-app-pub-3940256099942544/2934735716"
)

def handle_interstitial_close(e):
    nonlocal iad
    print("InterstitialAd closed")
    page.overlay.remove(e.control)
    page.overlay.append(iad := get_new_interstitial_ad())
    page.update()

def get_new_interstitial_ad():
    return ads.InterstitialAd(
        unit_id=id_interstitial,
        on_load=lambda e: print("InterstitialAd loaded"),
        on_error=lambda e: print("InterstitialAd error", e.data),
        on_open=lambda e: print("InterstitialAd opened"),
        on_close=handle_interstitial_close,
        on_impression=lambda e: print("InterstitialAd impression"),
        on_click=lambda e: print("InterstitialAd clicked"),
    )

def display_new_banner_ad():
    page.add(
        ft.Container(
            content=ads.BannerAd(
                unit_id=id_banner,
                on_click=lambda e: print("BannerAd clicked"),
                on_load=lambda e: print("BannerAd loaded"),
                on_error=lambda e: print("BannerAd error", e.data),
                on_open=lambda e: print("BannerAd opened"),
                on_close=lambda e: print("BannerAd closed"),
                on_impression=lambda e: print("BannerAd impression"),
                on_will_dismiss=lambda e: print("BannerAd will dismiss"),
            ),
            width=320,
            height=50,
            bgcolor=ft.colors.TRANSPARENT,
        )
    )

page.overlay.append(iad := get_new_interstitial_ad())
page.appbar = ft.AppBar(
    adaptive=True,
    title=ft.Text("Mobile Ads Playground"),
    bgcolor=ft.colors.LIGHT_BLUE_300,
)
page.add(
    ft.OutlinedButton("Show InterstitialAd", on_click=lambda e: iad.show()),
    ft.OutlinedButton("Show BannerAd", on_click=lambda e: display_new_banner_ad()),
)

ft.app(main)

To reproduce

run this code and try to build with 0.25.2 flet

Expected behavior

error when building

Screenshots / Videos

Captures

[Upload media here]

Operating System

Linux

Operating system details

dubian 11

Flet version

0.25.2

Regression

No, it isn't

Suggestions

I noticed that google_mobile_ads released a new version, 5.3.0, a few days ago. The app was working fine before this update

Logs

Logs
[Paste your logs here]

Additional details

No response

@flet-dev flet-dev deleted a comment Jan 25, 2025
@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Jan 26, 2025

I noticed that google_mobile_ads released a new version, 5.3.0, a few days ago. The app was working fine before this update

Strange. The version of google_mobile_ads used in Flet hasnt been changed since.

@zox47
Copy link
Author

zox47 commented Jan 26, 2025

I noticed that google_mobile_ads released a new version, 5.3.0, a few days ago. The app was working fine before this update

Strange. The version of google_mobile_ads used in Flet hasnt been changed since.

soo what the solution,?

@ndonkoHenri
Copy link
Contributor

Will come up with a video in some days showing how I build an app with ads.

@geceyzlm
Copy link

Will come up with a video in some days showing how I build an app with ads.

Thanks a lot

@geceyzlm
Copy link

Will come up with a video in some days showing how I build an app with ads.

Thanks a lot.

@zox47
Copy link
Author

zox47 commented Jan 27, 2025

Will come up with a video in some days showing how I build an app with ads.

thanks bro i will be waiting

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

3 participants