marcojak / MauiMTAdmob

MIT License
104 stars 17 forks source link

NULL object error on physical iOS device at start up #67

Closed Th3L0x closed 3 months ago

Th3L0x commented 4 months ago

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.MauiMTAdmob.MauiMTAdmob.Init(String license, String openAdsId, Boolean enableOpenAds, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography) at Maui.AppDelegate..ctor() in C:\Users\user\source\repos\Maui\Maui\Platforms\iOS\AppDelegate.cs:line 22 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)' The app has been terminated.

I got the error when I call CrossMauiMTAdmob.Current.Init(); in AppDelegate.cs constructor.

marcojak commented 4 months ago

Have you tried the sample code? Does it work? If it works and yours doesn't, do we have a demo test I can try?

Th3L0x commented 4 months ago

Yes I tried the sample code and I get this error too #66 If I modify the initialization to this (like in the sample): CrossMauiMTAdmob.Current.Init(license, OPENADS_AD_UNIT_ID, true, false, deviceId, Plugin.MauiMTAdmob.Extra.DebugGeography.DEBUG_GEOGRAPHY_EEA); With this it's not throwing any error, only when it's try to load the AdView on a page, like in #66

marcojak commented 4 months ago

Yesterday I've released version 1.3.0. Can you check if you still have the issue?

Also I've noticed that xcode 15.2 causes a lot of issues with Xamarin & MAUI. After going back to xcode 15.1, everything started to work as expected.

Th3L0x commented 4 months ago

Thank you! Currently I'm abroad but I will check ASAP.

Th3L0x commented 4 months ago

Hi, I checked with the latest version on physical iOS. If I use the "CrossMauiMTAdmob.Current.Init();" at AppDelegate I still get this error: An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.MauiMTAdmob.MauiMTAdmob.Init(String license, String nativeAdsId, String openAdsId, Boolean enableOpenAds, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography) at MauiApp.AppDelegate..ctor() in C:\Users\user\source\repos\MauiApp\MauiApp\Platforms\iOS\AppDelegate.cs:line 26 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)'

If I use the updated sample code the Init is fine "CrossMauiMTAdmob.Current.Init(license, NATIVEADS_AD_UNIT_ID, OPENADS_AD_UNIT_ID, areOpenAdsEnabled, false, deviceId, Plugin.MauiMTAdmob.Extra.DebugGeography.DEBUG_GEOGRAPHY_EEA);"

But when I navigate to a page that contains an MTAdView, then I still get this error:

{System.DllNotFoundException: Internal at Plugin.MauiMTAdmob.Platforms.iOS.MTAdViewHandler.CreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.MauiMTAdmob.Interfaces.IMTAdView, Plugin.MauiMtAdmob, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null],[Google.MobileAds.BannerView, Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.MauiMTAdmob.Interfaces.IMTAdView, Plugin.MauiMtAdmob, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null],[Google.MobileAds.BannerView, Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.MauiMTAdmob.Interfaces.IMTAdView, Plugin.MauiMtAdmob, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null],[Google.MobileAds.BannerView, Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateContentView(IScrollView scrollView, IScrollViewHandler handler, ICrossPlatformLayout crossPlatformLayout) at Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(IScrollViewHandler handler, IScrollView scrollView) at Microsoft.Maui.PropertyMapper`2.<>cDisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) at Microsoft.Maui.PropertyMapper2.<>cDisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.SetPageRenderer(Page page, ShellContent shellContent) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers() at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad() at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at MauiApp.Program.Main(String[] args) in C:\Users\user\source\repos\MauiApp\MauiApp\Platforms\iOS\Program.cs:line 15}

Th3L0x commented 4 months ago

Do you have any update on this?

marcojak commented 4 months ago

I was travelling for work so I couldn't spend too much time on it. So far I haven't been able to reproduce the issue. Are you sure you have the same issue on the sample code?

Th3L0x commented 4 months ago

Thank you, yes I think it's the same issue, the only difference is I get a DLL not found error at the begining

(This is what I get from the sample app) Thread started: #9 Thread started: #10 Thread started: #11 2024-02-28 23:12:08.443 Xamarin.PreBuilt.iOS[898:1120242] Could not resolve assembly System.Private.DataContractSerialization.resources, Version=8.0.0.0, Culture=hu, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/920F43BE-C2AD-4E67-8FD7-8FDD394D8A32/Documents/MMTAdmobSample.content/System.Private.DataContractSerialization.resources.dll' or one of its dependencies.

2024-02-28 23:12:08.439 Xamarin.PreBuilt.iOS[898:1120242] Could not resolve assembly System.Private.DataContractSerialization.resources, Version=8.0.0.0, Culture=hu-DE, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/920F43BE-C2AD-4E67-8FD7-8FDD394D8A32/Documents/MMTAdmobSample.content/System.Private.DataContractSerialization.resources.dll' or one of its dependencies.

[0:] An error occurred: 'Internal'. Callstack: ' at Plugin.MauiMTAdmob.Platforms.iOS.MTAdViewHandler.CreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.MauiMTAdmob.Interfaces.IMTAdView, Plugin.MauiMtAdmob, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null],[Google.MobileAds.BannerView, Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.MauiMTAdmob.Interfaces.IMTAdView, Plugin.MauiMtAdmob, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null],[Google.MobileAds.BannerView, Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.MauiMTAdmob.Interfaces.IMTAdView, Plugin.MauiMtAdmob, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null],[Google.MobileAds.BannerView, Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ProcessAutoPackage(IElement element) at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view, IPlatformViewHandler nativeViewHandler, Action1 onElementChanged, Frame& currentVirtualView, IPropertyMapper& _mapper, IPropertyMapper _defaultMapper, Boolean autoPackage) at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Microsoft.Maui.IElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateContentView(IScrollView scrollView, IScrollViewHandler handler, ICrossPlatformLayout crossPlatformLayout) at Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(IScrollViewHandler handler, IScrollView scrollView) at Microsoft.Maui.PropertyMapper2.<>cDisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) at Microsoft.Maui.PropertyMapper2.<>cDisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.ToUIViewController(IElement view, IMauiContext context) at Microsoft.Maui.Handlers.WindowHandler.MapContent(IWindowHandler handler, IWindow window) at Microsoft.Maui.PropertyMapper`2.<>cDisplayClass5_0[[Microsoft.Maui.IWindow, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IWindowHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.SetHandler(INativeObject nativeElement, IElement element, IMauiContext context) at Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler(UIWindow platformWindow, IWindow window, IMauiContext context) at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(IApplication application, UIWindowScene windowScene, NSDictionary[] states) at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(IUIApplicationDelegate platformApplication, IApplication application, UIApplication uiApplication, NSDictionary launchOptions) at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions) at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at MMTAdmobSample.Program.Main(String[] args) in C:\Users\Th3l0x\Downloads\MauiMTAdmob-master (1)\MauiMTAdmob-master\SampleMMTAdmob\Platforms\iOS\Program.cs:line 13 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)' The app has been terminated.

marcojak commented 4 months ago

I cannot reproduce the issue. Can you tell me something about your environment? OS, IDE, test device?

I'm also confused by "Xamarin.PreBuilt.iOS" in your logs.

Th3L0x commented 4 months ago

Sure, OS: windows10 IDE: latest visual studio, dotnet 8 Device: iphone 8, 16.x

marcojak commented 4 months ago

And how your iPhone is connected? Mac or Windows?

It seems that you don't have a local Mac. How does it work?

Th3L0x commented 4 months ago

The iPhone is connected directly to my Windows. It's intersting because everything else is working fine, I mean firebase notifications, authentications, map, camera, etc.

My friend tried the same project I'm working on, with Rider and Iphone connected to a Mac, and this way the ads are loaded in.

marcojak commented 4 months ago

I was just looking at an article I wrote for my blog xamarinexpert and I found this:

Limitations: ... Static iOS libraries and frameworks are not supported (your app will crash) ...

I guess that's the problem and probably they never solved this limitation.

So this doesn't seem an issue with the plugin itself but with Visual Studio.

It explains why it was working fine for me (I'm using a Mac connected to my Windows machine).

I'll see if there is anything I can do, but I doubt it.

Th3L0x commented 4 months ago

Okay thank you :/ Your IPhone is connected to your Windows or Mac?

marcojak commented 4 months ago

It's connected to my Mac.

So I've had a look around and I've seen a message about this Library on a Microsoft website and a guy from Microsoft confirmed that the package mobile.ads is not compatible with hot reload and it cannot be used directly from windows. If you want to use ads, you must have a Mac (unless Microsoft founds an alternative but I really don't believe they'll do).

On Fri, 1 Mar 2024, 10:33 Th3L0x, @.***> wrote:

Okay thank you :/ You IPhone is connected to your Windows or Mac?

— Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/67#issuecomment-1972835401, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPIWE75RDTDK3PGB2RX3YWBDNLAVCNFSM6AAAAABDRWAGEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSHAZTKNBQGE . You are receiving this because you commented.Message ID: @.***>

Th3L0x commented 4 months ago

That's bad news, okay thank you for the help, I think I will comment out the ad part when we test it on my Iphone.

marcojak commented 3 months ago

Closing as not an issue with the plugin

zafrkaya commented 3 weeks ago

I think the package cannot be tested on physical iOS devices connected to Windows due to issues that are not your fault. I don't have a Mac, I can run it on Android without any problems, but I get a similar license error on iOS. Does this mean that if I use this package, I won't be able to test iOS physical devices on Windows? Or does anyone have a workaround for this, I'm really confused :( @marcojak @Th3L0x

[0:] An error occurred: 'The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.'. Callstack: ' at System.Convert.FromBase64CharPtr(Char inputPtr, Int32 inputLength) at System.Convert.FromBase64String(String s) at Plugin.MauiMTAdmob.License.AESGCMDecrypt(String encryptedText, String ekey, String nkey) at Plugin.MauiMTAdmob.License.ValidateLicenseKey(String licenseKey) at Plugin.MauiMTAdmob.License.SetLicenseKey(String key) at Plugin.MauiMTAdmob.MauiMTAdmob.Init(String license, String nativeAdsId, String openAdsId, Boolean enableOpenAds, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography) at Swiplore.MobileApp.AppDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions) in C:\Users\antfi\source\repos\zafrkaya\Swiplore\Swiplore.MobileApp\Platforms\iOS\AppDelegate.cs:line 15 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at Swiplore.MobileApp.Program.Main(String[] args) in C:\Users\antfi\source\repos\zafrkaya\Swiplore\Swiplore.MobileApp\Platforms\iOS\Program.cs:line 13 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr args) at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)' The app has been terminated.

Th3L0x commented 3 weeks ago

Yes, unfortunately it didn't work while I built the project from Windows:/ I bought a Macbook and it worked.

zafrkaya commented 3 weeks ago

In order not to give up on the package completely, I came up with such a solution today. I am testing the ads on Android, hoping that they will work on iOS prod. I'll do without buying a Mac for a while. :)

            #if !DEBUG && !__IOS__
            CrossMauiMTAdmob.Current.Init(); // Reklam hizmetini başlat
            #endif
marcojak commented 3 weeks ago

In order not to give up on the package completely, I came up with such a solution today. I am testing the ads on Android, hoping that they will work on iOS prod. I'll do without buying a Mac for a while. :)

            #if !DEBUG && !__IOS__
            CrossMauiMTAdmob.Current.Init(); // Reklam hizmetini başlat
            #endif

This is the correct solution when a Mac is not available. If you remember to use the proper ads Ids per iOS, then if the implementation works for Android, it will work for iOS too!