native_admob_flutter
native_admob_flutter copied to clipboard
Native Ad not working - MissingPluginException
E/flutter ( 6502): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method loadAd on channel [#c3489])
E/flutter ( 6502): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165)
E/flutter ( 6502): <asynchronous suspension>
E/flutter ( 6502): #1 Future.timeout.<anonymous closure> (dart:async/future_impl.dart:873)
E/flutter ( 6502): <asynchronous suspension>
E/flutter ( 6502): #2 NativeAdController.load (package:native_admob_flutter/src/native/controller/controller.dart:396)
E/flutter ( 6502): <asynchronous suspension>
its working fine on iOS. I am getting error above on android
Any update I'm facing the same issue after upgrading to Flutter 2.8.0
I can't reproduce this
Any update I'm facing the same issue after upgrading to Flutter 2.8.0
I had this issue too, on Flutter 2.8.0 with dart 2.15.0
@bdlukaa try to change pages with banner ad on each page. Then you will see
I also upgraded Flutter to 2.8.0 and started to encounter this problem (with native ads) on Android. Can't say for other platforms.
I can't reproduce this @bdlukaa I try with the example app and Flutter 2.8.0-stable and the error occurs. The device that i use to test it was Huawei P20 with Android 9.
I've published my app into release version with Flutter 2.8 and Dart 2.15.0 and got a lot of crashes on splash because of AppOpen Ad
Click here to see the last 30 min crash event report
That's because I didn't involve it into a try catch (and never think about it) I'll try to involve it or remove if is not successed
same problem when I upgraded Flutter to 2.8.0
Same also with macos Flutter 2.8.0, android physical device
Problem is continues. This is the flutter doctor result.
Flutter 2.9.0-0.1.pre • channel beta • https://github.com/flutter/flutter.git Framework • revision 8f1f9c10f0 (15 hours ago) • 2021-12-14 13:41:48 -0800 Engine • revision 234aca678a Tools • Dart 2.16.0 (build 2.16.0-80.1.beta) • DevTools 2.9.1
Running flutter doctor... Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel beta, 2.9.0-0.1.pre, on Microsoft Windows [Version 10.0.19043.1348], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [√] Chrome - develop for the web [√] Android Studio (version 2020.3) [√] Connected device (3 available)
• No issues found!
@bdlukaa were you able to simulate this error? It's for all ads, not only native.
@bdlukaa were you able to simulate this error? It's for all ads, not only native. In my case it occurs in all type of ads.
Any update on this. This plugin is so useful because the official is so buggy.
same problem when I upgraded Flutter to 2.8.1
I can't reproduce this
rewardvideo
I recommend you all change to official package. I think this one is no longer maintained due to unapproved PRs and I saw that the package is no longer in the author's pins :sweat_smile:
I recommend you all change to official package. I think this one is no longer maintained due to unapproved PRs and I saw that the package is no longer in the author's pins 😅 which package can be recommended please?
@wl1395182472
which package can be recommended please?
https://pub.dev/packages/google_mobile_ads
@wl1395182472
which package can be recommended please?
https://pub.dev/packages/google_mobile_ads
thank
same problem when I upgraded Flutter to 2.8.1
@bdlukaa fix it please! This plugin is very good!
+1
Hi,
You can check out my commit for lib/src/native/native_ad_widget.dart.
I changed the _load method to be a future and wait for it to finish in the initstate, looks more solid.
if (!controller.isLoaded) {
WidgetsBinding.instance?.addPostFrameCallback((_) async {
await _load();
});
}
Before this issue occurred all the time with native ads on changing pages, especially after upgrading to the latest flutter version. With this change everything looks ok, tested it and didn't occur anymore.
Right now I don't have the time to change this in all the ad types and test it because Christmas and stuff, maybe after the holidays, if it makes sense.
Please have a look if this solution works for you or if it can be improved.
Thanks for the great package, performance is much better than the official google one.
void init() async {
channel.setMethodCallHandler(_handleMessages);
await MobileAds.pluginChannel.invokeMethod('initRewardedAd', {'id': id});
}
init method donot wait initRewardedAd
,you can load with delay
final ad = RewardedAd(
unitId: "xxxx",
loadTimeout: const Duration(seconds: 10),
timeout: const Duration(seconds: 10)
);
// wait initRewardedAd
await Future.delayed(Duration(milliseconds: 100));
// load ad
await ad.load();
Hi,
You can check out my commit for lib/src/native/native_ad_widget.dart.
I changed the _load method to be a future and wait for it to finish in the initstate, looks more solid.
if (!controller.isLoaded) { WidgetsBinding.instance?.addPostFrameCallback((_) async { await _load(); }); }
Before this issue occurred all the time with native ads on changing pages, especially after upgrading to the latest flutter version. With this change everything looks ok, tested it and didn't occur anymore.
Right now I don't have the time to change this in all the ad types and test it because Christmas and stuff, maybe after the holidays, if it makes sense.
Please have a look if this solution works for you or if it can be improved.
Thanks for the great package, performance is much better than the official google one.
It looks like this solution doesn't work, still got a lot of errors in production from several users.
The root cause is that the initialization MethodChannel
has not been completed when the advertisement is loaded. Therefore, the above answer and delay cannot completely solve the problem. You must use the synchronous method and wait for theMethodChannel
to be initialized before calling the load method. This can be completely solved.
The root cause is that the initialization
MethodChannel
has not been completed when the advertisement is loaded. Therefore, the above answer and delay cannot completely solve the problem. You must use the synchronous method and wait for theMethodChannel
to be initialized before calling the load method. This can be completely solved.
How to implement this? Do we need to change the plugin's source or need to change our app source?
The root cause is that the initialization
MethodChannel
has not been completed when the advertisement is loaded. Therefore, the above answer and delay cannot completely solve the problem. You must use the synchronous method and wait for theMethodChannel
to be initialized before calling the load method. This can be completely solved.How to implement this? Do we need to change the plugin's source or need to change our app source?
You can try this commit. Fix bug
@mondongx I've tried with your fork, but the error still persists.
@davidgalarza Can you provide flutter doctor result and exception stack?
@mondongxr Thanks for the reply.
Flutter doctor output:
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.6 20G165 darwin-x64, locale es-EC)
• Flutter version 2.8.1 at /Users/macbook/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/macbook/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.32.0
[✓] Connected device (1 available)
• ANE LX3 (mobile) • KPS7N18425000775 • android-arm64 • Android 9 (API 28)
• No issues found!
Error Stack
I/flutter ( 7709): ----------------FIREBASE CRASHLYTICS----------------
I/flutter ( 7709): MissingPluginException(No implementation found for method loadAd on channel [#69265])
I/flutter ( 7709):
I/flutter ( 7709): #0 MethodChannel._invokeMethod
package:flutter/lib/src/services/platform_channel.dart:165
I/flutter ( 7709): <asynchronous suspension>
I/flutter ( 7709): #1 Future.timeout.<anonymous closure> (dart:async/future_impl.dart)
I/flutter ( 7709): <asynchronous suspension>
I/flutter ( 7709): #2 BannerAdController.load
package:native_admob_flutter-bfe81a52236bb3a1ac05d7eb06e9fd98a9f45ae0/lib/src/banner/controller.dart:230
I/flutter ( 7709): <asynchronous suspension>
I/flutter ( 7709): ----------------------------------------------------
build.gradle:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "..."
minSdkVersion 21
targetSdkVersion 31
compileSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
The error occurs randomly about every 5 of 10 times that I navigate to a new page with a banner ad.