Skip to content
This repository has been archived by the owner on Mar 12, 2022. It is now read-only.

Native Ad not working - MissingPluginException #114

Open
terrasuscompany opened this issue Nov 3, 2021 · 35 comments
Open

Native Ad not working - MissingPluginException #114

terrasuscompany opened this issue Nov 3, 2021 · 35 comments

Comments

@terrasuscompany
Copy link

terrasuscompany commented Nov 3, 2021

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

@davidgalarza
Copy link

Any update I'm facing the same issue after upgrading to Flutter 2.8.0

@bdlukaa
Copy link
Owner

bdlukaa commented Dec 11, 2021

I can't reproduce this

@marcellocamara
Copy link

marcellocamara commented Dec 11, 2021

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

@yom-ko
Copy link

yom-ko commented Dec 11, 2021

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.

@davidgalarza
Copy link

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.

@marcellocamara
Copy link

marcellocamara commented Dec 12, 2021

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

@mzarhou
Copy link

mzarhou commented Dec 12, 2021

same problem when I upgraded Flutter to 2.8.0

@pyaehein
Copy link

Same also with macos Flutter 2.8.0, android physical device

@terrasuscompany terrasuscompany changed the title Native Ad not working Native Ad not working - MissingPluginException Dec 15, 2021
@terrasuscompany
Copy link
Author

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!

@marcellocamara
Copy link

@bdlukaa were you able to simulate this error? It's for all ads, not only native.

@davidgalarza
Copy link

@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.

@davidgalarza
Copy link

Any update on this. This plugin is so useful because the official is so buggy.

@ghostgzt
Copy link

same problem when I upgraded Flutter to 2.8.1

@ghostgzt
Copy link

I can't reproduce this

rewardvideo

@marcellocamara
Copy link

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 😅

@wl1395182472
Copy link

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?

@marcellocamara
Copy link

@wl1395182472

which package can be recommended please?

https://pub.dev/packages/google_mobile_ads

@wl1395182472
Copy link

@wl1395182472

which package can be recommended please?

https://pub.dev/packages/google_mobile_ads

thank

@brahimaito
Copy link

same problem when I upgraded Flutter to 2.8.1

@ghostgzt
Copy link

@bdlukaa fix it please! This plugin is very good!

@admincode1
Copy link

+1

@kreativityapps
Copy link

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.

@zhengbomo
Copy link
Contributor

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();

@kreativityapps
Copy link

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.

@mondongxr
Copy link

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.

@gadgetreviews
Copy link

gadgetreviews commented Jan 6, 2022

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?

mondongxr pushed a commit to mondongxr/native_admob_flutter that referenced this issue Jan 6, 2022
Ensure that MethodChannel is initialized before invoke the loadAd method.
@mondongxr
Copy link

mondongxr commented Jan 6, 2022

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

@davidgalarza
Copy link

davidgalarza commented Jan 16, 2022

@mondongx I've tried with your fork, but the error still persists.

@mondongxr
Copy link

@davidgalarza Can you provide flutter doctor result and exception stack?

@davidgalarza
Copy link

@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.

@mondongxr
Copy link

@davidgalarza It's not the same issue, because the log you provided that banner ads are loaded, not native ads. The repair method of banner ads is different from that of native ads.

@mondongxr
Copy link

@davidgalarza It's not the same issue, because the log you provided that banner ads are loaded, not native ads. The repair method of banner ads is different from that of native ads.

Fix bug "MissingPluginException" on loading banner ad
4375191

@terrasuscompany
Copy link
Author

Any new answer? @bdlukaa please help. it s working fine with flutter 2.6.0-5.2.pre. i downgrade it. But its not working with newer versions.

@alexandr-efimov
Copy link

alexandr-efimov commented Feb 13, 2022

Reproduced for native ads in case usage in feed - with multiple ad items.

E/flutter ( 8235): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method loadAd on channel [#d6327]) E/flutter ( 8235): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7) E/flutter ( 8235): <asynchronous suspension> E/flutter ( 8235): #1 Future.timeout.<anonymous closure> (dart:async/future_impl.dart:870:15) E/flutter ( 8235): <asynchronous suspension> E/flutter ( 8235): #2 NativeAdController.load (package:native_admob_flutter/src/native/controller/controller.dart:396:17) E/flutter ( 8235): <asynchronous suspension> E/flutter ( 8235):

Any updates with solutions/workarounds?

With latest flutter plugin not work with Native ads for Android.
Flutter (Channel stable, 2.10.1, on macOS 11.6 20G165 darwin-x64, locale ru-UA)

@gustavomrfz
Copy link

I got this error and stopped getting it when I put in main.dart:

String get nativeAdUnitId {
  String adNativeId = "ca-app-pub-3940256099942544/2247696110"; //Test AD
  return adNativeId;
}

I am aware that the question will sound arrogant, but are you sure that the native ID you use is correct? In previous versions, there was a check that the ID was correct and if not it used the test ID, but I think it doesn't do that now.

[✓] Flutter (Channel master, 2.10.0-1.0.pre.377, on Pop!_OS 21.10 5.15.15-76051515-generic, locale es_ES.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[✓] VS Code (version 1.64.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability```

native_admob_flutter: ^1.5.0`

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