-
Notifications
You must be signed in to change notification settings - Fork 277
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
[Android] Ads won't load with location
parameter in AdRequest
#449
Labels
bug
Something isn't working
e2-days
Effort: < 5 days
fixed
Issue has been resolved and pull request linked
p2-medium
platform-android
Android applications specifically
Comments
Hi @timhoffmannGIThub, Thanks for filing the issue. I am able to reproduce the issue. Ads don't load when the location is passed to AdRequest. This issue is only reproducible on Android and works fine on IOS. code sampleimport 'dart:io';
import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(home: AdSample());
}
}
class AdSample extends StatefulWidget {
const AdSample({Key? key}) : super(key: key);
@override
_AdSampleState createState() => _AdSampleState();
}
class _AdSampleState extends State<AdSample> {
BannerAd? _bannerAd;
bool _bannerAdIsLoaded = false;
@override
void initState() {
super.initState();
_bannerAd = BannerAd(
size: AdSize.banner,
adUnitId: Platform.isAndroid
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716',
listener: BannerAdListener(
onAdLoaded: (Ad ad) {
print('BannerAd loaded.');
setState(() {
_bannerAdIsLoaded = true;
});
},
onAdFailedToLoad: (Ad ad, LoadAdError error) {
print('BannerAd failedToLoad: $error');
ad.dispose();
},
onAdOpened: (Ad ad) => print('BannerAd onAdOpened.'),
onAdClosed: (Ad ad) => print('BannerAd onAdClosed.'),
),
request: const AdRequest(
location: LocationParams(
accuracy: 5.0, longitude: 8.677343, latitude: 50.581060)))
..load();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Video player'),
),
resizeToAvoidBottomInset: false,
body: Container(
height: 200,
alignment: Alignment.center,
child: _buildView(),
),
);
}
Widget _buildView() {
return Column(
children: [
_bannerAdView(),
],
);
}
Widget _bannerAdView() {
final BannerAd? bannerAd = _bannerAd;
if (_bannerAdIsLoaded && bannerAd != null) {
return SizedBox(
height: bannerAd.size.height.toDouble(),
width: bannerAd.size.width.toDouble(),
child: AdWidget(ad: bannerAd));
} else {
return Container();
}
}
@override
void dispose() {
_bannerAd?.dispose();
super.dispose();
}
}
flutter doctor -v
logsLaunching lib/main.dart on Redmi K20 Pro in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
W/FlutterActivityAndFragmentDelegate(21559): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Connecting to VM Service at ws://127.0.0.1:53802/R9UVWP9S-nQ=/ws
E/flutter (21559): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value
E/flutter (21559): #0 MethodChannel.binaryMessenger
E/flutter (21559): #1 MethodChannel._invokeMethod
E/flutter (21559): #2 MethodChannel.invokeMethod
E/flutter (21559): #3 PlatformViewsService.synchronizeToNativeViewHierarchy
E/flutter (21559): #4 main
E/flutter (21559): #5 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:145:25)
E/flutter (21559): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter (21559): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter (21559): #8 _runZoned (dart:async/zone.dart:1863:10)
E/flutter (21559): #9 runZonedGuarded (dart:async/zone.dart:1851:12)
E/flutter (21559): #10 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:141:5)
E/flutter (21559): #11 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)
E/flutter (21559): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (21559):
D/SurfaceView(21559): UPDATE null, mIsCastMode = false
I/ple.ads_exampl(21559): ProcessProfilingInfo new_methods=1123 is saved saved_to_disk=1 resolve_classes_delay=8000
W/Looper (21559): PerfMonitor doFrame : time=638ms vsyncFrame=13195823 latency=14ms procState=2 historyMsgCount=1
E/DartMessenger(21559): Uncaught exception in binary message listener
E/DartMessenger(21559): java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
E/DartMessenger(21559): at io.flutter.plugins.googlemobileads.AdMessageCodec.readValueOfType(AdMessageCodec.java:337)
E/DartMessenger(21559): at io.flutter.plugins.googlemobileads.AdMessageCodec.readValueOfType(AdMessageCodec.java:240)
E/DartMessenger(21559): at io.flutter.plugin.common.StandardMessageCodec.readValue(StandardMessageCodec.java:333)
E/DartMessenger(21559): at io.flutter.plugin.common.StandardMessageCodec.readValueOfType(StandardMessageCodec.java:426)
E/DartMessenger(21559): at io.flutter.plugins.googlemobileads.AdMessageCodec.readValueOfType(AdMessageCodec.java:340)
E/DartMessenger(21559): at io.flutter.plugin.common.StandardMessageCodec.readValue(StandardMessageCodec.java:333)
E/DartMessenger(21559): at io.flutter.plugin.common.StandardMethodCodec.decodeMethodCall(StandardMethodCodec.java:48)
E/DartMessenger(21559): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/DartMessenger(21559): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/DartMessenger(21559): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/DartMessenger(21559): at android.os.MessageQueue.nativePollOnce(Native Method)
E/DartMessenger(21559): at android.os.MessageQueue.next(MessageQueue.java:335)
E/DartMessenger(21559): at android.os.Looper.loop(Looper.java:193)
E/DartMessenger(21559): at android.app.ActivityThread.main(ActivityThread.java:8061)
E/DartMessenger(21559): at java.lang.reflect.Method.invoke(Native Method)
E/DartMessenger(21559): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
E/DartMessenger(21559): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
E/flutter (21559): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method loadBannerAd on channel plugins.flutter.io/google_mobile_ads)
E/flutter (21559): #0 MethodChannel._invokeMethod
E/flutter (21559): <asynchronous suspension>
E/flutter (21559): #1 BannerAd.load
E/flutter (21559): <asynchronous suspension>
E/flutter (21559):
|
maheshj01
added
bug
Something isn't working
e2-days
Effort: < 5 days
p2-medium
platform-android
Android applications specifically
and removed
in triage
Issue currently being evaluated
labels
Nov 26, 2021
maheshj01
changed the title
(Android) Ads won't load with 'location' parameter
[Android] Ads won't load with 'location' parameter in AdRequest
Nov 26, 2021
maheshj01
changed the title
[Android] Ads won't load with 'location' parameter in AdRequest
[Android] Ads won't load with Nov 26, 2021
location
parameter in AdRequest
10 tasks
Should be fixed by #452, in v1.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
e2-days
Effort: < 5 days
fixed
Issue has been resolved and pull request linked
p2-medium
platform-android
Android applications specifically
Plugin Version
google_mobile_ads: 1.0.0
Steps to Reproduce
Get the User's location or use dummy data with the type LocationParams, like this:
Implement the RewardedAd.load method like this:
So that the parameter location gets the information from our dummy data.
Expected results: Ads should load with the personalized information.
Actual results: On iOS it loads them correctly, on Android the ads won't load with an error failing to read the values.
Logs
The text was updated successfully, but these errors were encountered: