Closed erperejildo closed 3 years ago
Could you show your whole banner ad code implementation please?
I didn't mention it but I had running before firebase_admob
so all admob/ios/android setup it's fine
import 'dart:io';
import 'package:google_mobile_ads/google_mobile_ads.dart';
class AdState {
Future<InitializationStatus> initialization;
AdState(this.initialization);
String get bannerAdUnitId => Platform.isAndroid
? 'idANDROID'
: 'idIOS';
AdListener get adListener => _adListener;
AdListener _adListener = AdListener(
onAdLoaded: (ad) => print("ad loaded ${ad.adUnitId}"),
onAdOpened: (ad) => print("ad loaded ${ad.adUnitId}"),
onAdClosed: (ad) => print("ad loaded ${ad.adUnitId}"),
);
}
final initFuture = MobileAds.instance.initialize();
final adState = AdState(initFuture);
runApp(
LocalizedApp(
delegate,
Provider.value(
value: adState,
builder: (context, child) => MyApp(),
),
),
);
Above the code I put on the question I have this:
@override
void didChangeDependencies() {
super.didChangeDependencies();
final adState = Provider.of<AdState>(context);
adState.initialization.then((status) {
setState(() {
banner = BannerAd(
adUnitId: adState.bannerAdUnitId,
size: AdSize.banner,
request: AdRequest(),
listener: adState.adListener,
)..load();
});
});
}
I followed as mentioned the approach described in the Flutter Engage presentation. I noticed it's not the same as you proposed in the README.
To be honest I feel I bit lost with the official way to display ads in Flutter. I was using firebase_admob
and it was working fine but now they presented this package and didn't mention what to do with the previous one. Is it deprecated? And should we follow the approach described here or the one from the video?
More info
Despite this triggers:
This never does it:
@erperejildo did you figure this out, i'm having the same problem, also used to work with the previous firebase package here?
@erperejildo did you figure this out, i'm having the same problem, also used to work with the previous firebase package here?
No, and I have to say that I also created a new project from scratch and copied my files to it
No comments yet?
Hi @erperejildo, Thanks for filing the issue, I was able to run the ads sample code on the latest stable channel of flutter with google_mobile_Ads: ^0.13.2
could you please try this sample code on the latest stable version of flutter and see if this helps.
Thank you.
I see it working now. Thanks
Hi @erperejildo, Thanks for filing the issue, I was able to run the ads sample code on the latest stable channel of flutter with
google_mobile_Ads: ^0.13.2
could you please try this sample code on the latest stable version of flutter and see if this helps.code sample flutter doctor -v Thank you.
do you know why the app is extremely slow while showing the ads?
@erperejildo I did not see such behavior, If you do feel free to raise another issue with the appropriate reproducible steps.
Thanks
Bug report
It doesn't display any banner and if I refresh the state of my app it throws an error and closes it
Steps to reproduce
I followed exactly the same steps described here: https://youtu.be/yll3SNXvQCw?t=13995
Expected behavior
I should see the banner
Additional context
You can see the empty block without banner here at the bottom:
If I refresh at this point this is the error that I get before losing the connection with the emulator:
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` [✓] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 12.4) [!] Android Studio (version 4.1) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. <---- these 2 lines are fine [✓] Connected device (1 available) ! Doctor found issues in 1 category. ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` - add_2_calendar 1.4.0 [flutter] - admob_flutter 1.0.1 [flutter meta] - after_init 0.1.2 [flutter] - apple_sign_in 0.1.0 [flutter] - cached_network_image 2.5.0 [flutter flutter_cache_manager octo_image] - carousel_slider 2.3.4 [flutter] - characters 1.1.0-nullsafety.3 - cloud_firestore 0.14.4 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web] - cloudinary_client 0.0.9 [dio crypto] - cloudinary_public 0.6.2 [flutter dio] - contacts_service 0.4.6 [flutter collection quiver] - country_currency_pickers 1.0.1 [flutter] - country_pickers 1.3.0 [flutter] - cupertino_icons 1.0.0 - dapackages 1.4.0 [yaml http] - device_info 0.4.2+10 [flutter device_info_platform_interface] - drag_and_drop_gridview 1.0.8 [flutter] - file_picker 2.1.6 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface] - firebase_analytics 6.3.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface] - firebase_auth 0.18.4+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter] - firebase_core 0.5.3 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - flappy_search_bar 1.7.2 [flutter async flutter_staggered_grid_view] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_cupertino_localizations 1.0.1 [flutter flutter_localizations] - flutter_downloader 1.5.2 [flutter] - flutter_email_sender 3.0.1 [flutter] - flutter_facebook_login 3.0.0 [flutter collection] - flutter_google_places 0.2.6 [flutter rxdart google_maps_webservice http] - flutter_launcher_icons 0.8.1 [image args yaml path] - flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math] - flutter_native_splash 0.1.9 [yaml image color] - flutter_open_whatsapp 0.1.2 [flutter] - flutter_platform_widgets 0.70.2 [flutter] - flutter_staggered_grid_view 0.3.3 [flutter] - flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml] - flutter_translate 1.6.0 [flutter flutter_device_locale] - google_mobile_ads 0.11.0+1 [meta flutter] - google_sign_in 4.5.9 [google_sign_in_platform_interface flutter meta google_sign_in_web] - http 0.12.2 [http_parser path pedantic] - image 2.1.19 [archive xml meta] - image_picker 0.6.7+22 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - in_app_purchase 0.3.5+1 [async collection flutter json_annotation meta] - intl 0.16.1 [path] - intl_phone_number_input 0.5.2+2 [flutter meta libphonenumber equatable] - maps_launcher 1.2.2+2 [flutter flutter_web_plugins url_launcher] - open_file 3.0.3 [flutter ffi] - package_info 0.4.3+4 [flutter] - path_provider 1.6.27 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - pdf 1.13.0 [archive barcode crypto image meta path_parsing vector_math xml] - permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface] - printing 3.7.2 [flutter flutter_web_plugins image js meta pdf plugin_platform_interface] - progress_dialog 1.2.4 [flutter] - provider 4.3.3 [collection flutter nested] - reorderables 0.3.2 [flutter] - shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - table_calendar 2.3.3 [flutter intl simple_gesture_detector] - transparent_image 1.0.0 - url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows] - uuid 2.2.2 [crypto convert] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - archive 2.0.13 [crypto args path] - args 1.6.0 - async 2.5.0-nullsafety.1 [collection] - barcode 1.17.1 [meta qr] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - charcode 1.2.0-nullsafety.1 - clock 1.1.0-nullsafety.1 - cloud_firestore_platform_interface 2.2.1 [flutter meta collection firebase_core plugin_platform_interface] - cloud_firestore_web 0.2.1+2 [flutter flutter_web_plugins http_parser meta firebase_core firebase_core_web cloud_firestore_platform_interface js] - collection 1.15.0-nullsafety.3 - color 2.1.1 - convert 2.1.1 [charcode typed_data] - crypto 2.1.5 [collection convert typed_data] - device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - dio 3.0.10 [http_parser path] - equatable 1.2.5 [collection meta] - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 5.2.1 [intl meta path] - firebase 7.3.3 [http http_parser js] - firebase_analytics_platform_interface 1.0.3 [flutter meta] - firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta] - firebase_auth_platform_interface 2.1.4 [flutter meta firebase_core plugin_platform_interface] - firebase_auth_web 0.3.2+3 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js] - firebase_core_platform_interface 2.1.0 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1+1 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - flutter_blurhash 0.5.0 [flutter meta] - flutter_cache_manager 2.1.1 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image] - flutter_device_locale 0.4.0 [flutter flutter_web_plugins plugin_platform_interface] - flutter_plugin_android_lifecycle 1.0.11 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - google_maps_webservice 0.0.19 [http meta] - google_sign_in_platform_interface 1.1.2 [flutter meta quiver] - google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - image_picker_platform_interface 1.1.6 [flutter meta http plugin_platform_interface] - js 0.6.2 - json_annotation 3.1.1 - libphonenumber 1.0.2 [flutter meta] - matcher 0.12.10-nullsafety.1 [stack_trace] - meta 1.3.0-nullsafety.3 - nested 0.0.4 [flutter] - octo_image 0.3.0 [flutter flutter_blurhash] - path 1.8.0-nullsafety.1 - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 0.0.4+8 [flutter] - path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.9.2 [meta] - permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - petitparser 3.1.0 [meta] - platform 2.2.1 - plugin_platform_interface 1.0.3 [meta] - process 3.0.13 [file intl meta path platform] - qr 1.3.0 [meta] - quiver 2.1.5 [matcher meta] - rxdart 0.24.1 - shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 1.0.4 [meta flutter] - shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 0.0.2+2 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows] - simple_gesture_detector 0.1.6 [flutter] - sky_engine 0.0.99 - source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph] - sqflite 1.3.2+2 [flutter sqflite_common path] - sqflite_common 1.0.3+1 [synchronized path meta] - stack_trace 1.10.0-nullsafety.1 [path] - stream_channel 2.1.0-nullsafety.1 [async] - string_scanner 1.1.0-nullsafety.1 [charcode source_span] - synchronized 2.2.0+2 - term_glyph 1.2.0-nullsafety.1 - test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.0-nullsafety.3 [collection] - url_launcher_linux 0.0.1+4 [flutter] - url_launcher_macos 0.0.1+9 [flutter] - url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface] - url_launcher_web 0.1.5+3 [url_launcher_platform_interface flutter flutter_web_plugins meta] - url_launcher_windows 0.0.1+3 [flutter] - vector_math 2.1.0-nullsafety.3 - win32 1.7.4+1 [ffi] - xdg_directories 0.1.2 [meta path process] - xml 4.5.1 [collection convert meta petitparser] - yaml 2.2.1 [charcode collection string_scanner source_span]```