MTAdmob icon indicating copy to clipboard operation
MTAdmob copied to clipboard

Null reference on iOS when adding banner to page

Open GreenleafDk opened this issue 1 year ago • 4 comments

MTAdmob 1.9.0.6 Xamarin forms 5.0.0.2545 iOS 15.7.5

Works fine on Android but crashes for iOS with ObjectReference not set to an instance of an object.mscorelib at Google.MobileAds.AdSizeCons.get_Banner() at MarcTron.Plugin.Renderers-AdViewRenderer.GetAdSize

Basic repro case:

New empty page

public PageName() { InitializeComponent() ; MYAdView adv = MTAdView(); StackLayoutOnPage.Children.Add(adv); }

On adding to the UI, the null reference is thrown. Tried setting this up in multiple ways, in xaml and in code, with and without setting the properties for banner type, size, addId etc. Always fails on this basic initial rendering. Same settings work fine without issue for android.

GreenleafDk avatar Jun 02 '23 15:06 GreenleafDk

Hi @GreenleafDk, were you able to resolve this issue, I have been battling for a few days now but haven't got into any solution yet. Much appreciated if you have any comments, please

peterrexj avatar Oct 29 '23 12:10 peterrexj

Yes and no. This was tested, and failing, on a physical ipad and iphone, both a bit dated, and it failed when debugging locally (both debug and release)... but when making a release build for ios store and installing from there, and then running, on those same two devices, there was no issue. This may or may not be helpful for you, and I honestly don't understand exactly what is going on, but the issue became a bit of a non issue that way. Same was happened with an issue with microsoft appcenter, which crashed on null exception in test (debug and release builds), but worked fine when installing from store and then running. If this makes sense to you, or anyone else, please do tell.

GreenleafDk avatar Oct 29 '23 13:10 GreenleafDk

Thanks for your response @GreenleafDk, you are lucky to get it working, for me it's crashing on physical device both from local and from the store (returning null) but works perfectly on the simulator. I might have to disable it for now unless @marcojak comes out with any solution.

peterrexj avatar Oct 30 '23 06:10 peterrexj

Hi, let me have a look if I can identify the issue and release a new version that fixes the issue.

marcojak avatar Oct 30 '23 16:10 marcojak