EddyVerbruggen / nativescript-admob

NativeScript plugin to earn some precious :moneybag::moneybag: with ads by Google AdMob
MIT License
69 stars 26 forks source link

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

Open brndusic opened 5 years ago

brndusic commented 5 years ago

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 commented 5 years ago

That's this line:

https://github.com/EddyVerbruggen/nativescript-admob/blob/677e83898d5640e60cd3ba7b5131c195362f3f6b/src/admob.android.js#L269

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

EddyVerbruggen commented 5 years ago

OK, so why doesn't the plugin work for you without you having to add that line? 🤔I mean, a similar line is here: https://github.com/EddyVerbruggen/nativescript-admob/blob/402c9ffc63a9e8a8972d55697a3e665e27da8a99/src/platforms/android/include.gradle#L11

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