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

TypeError: Cannot read property 'getRewardedVideoAdInstance' of undefined #55

Open
brndusic opened this issue Feb 10, 2019 · 5 comments

Comments

@brndusic
Copy link

Calling preloadRewardedVideoAd fails with errors:

JS: Error in admob.preloadRewardedVideoAd: TypeError: Cannot read property 'getRewardedVideoAdInstance' of undefined

JS: TypeError: Cannot read property 'getRewardedVideoAdInstance' of undefined

I have no Idea how to fix this. Can anyone help?

@EddyVerbruggen
Copy link
Owner

That's this line:

admob.videoView = com.google.android.gms.ads.MobileAds.getRewardedVideoAdInstance(admob._getActivity());

I think you Play Services version on your build machine may be outdated - can you update your SDKs and play repo through Android Studio?

@brndusic
Copy link
Author

Hi,
found what was problem. I haven't added to MobileAds to gradle dependencies

dependencies { compile 'com.google.android.gms:play-services-ads:17.1.2' }

Maybe this should be added to readme?

@EddyVerbruggen
Copy link
Owner

Hi! That should not be necessary. I wonder if it's caused by this change, where compile (which you have as well) changed to implementation.

What happens if you change compile to implementation and remove the platforms/android folder, and build again?

@brndusic
Copy link
Author

OK, I can confirm that it works fine after cleaning project and changing compile to implementation.

@EddyVerbruggen
Copy link
Owner

OK, so why doesn't the plugin work for you without you having to add that line? 🤔I mean, a similar line is here:

implementation "com.google.android.gms:play-services-ads:$googlePlayServicesVersion"

Does your App_Resources/Android/app.gradle file perhaps specify a play services version (that's too low)?

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

2 participants