MauiMTAdmob icon indicating copy to clipboard operation
MauiMTAdmob copied to clipboard

Setup with consent crashes on iOS physical device

Open MoienTajik opened this issue 5 months ago • 4 comments

I set up the plugin to use consent like this:

AppDelegate.cs:

public AppDelegate()
    {
        CrossMauiMTAdmob.Current.Init(
            Constants.Ads.LicenseKey,
            null,
            Constants.Ads.iOS.AppOpenAdUnitId,
            true,
            false,
            Constants.Ads.iOS.TestDeviceId,
            DebugGeography.DEBUG_GEOGRAPHY_EEA
        );
    }

Program.cs:

public static class Program
{
    private static void Main(string[] args)
    {
        UIApplication.Main(args, null, typeof(AppDelegate));
    }
}

With this setup, everything works on the emulator, but on a real device (iOS 18), I get this error, and then the app crashes:

2024-09-03 00:58:31.789 MyApplication.Client.Mobile[42901:4480132] MTAdmob correctly licensed
2024-09-03 00:58:32.097 MyApplication.Client.Mobile[42901:4480132] 
Unhandled Exception:
ObjCRuntime.RuntimeException: Could not find the type 'ObjCRuntime.__Registrar__' in the assembly 'Google.UserMessagingPlatform'.
   at ObjCRuntime.RegistrarHelper.GetMapEntry(String ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/RegistrarHelper.cs:line 105
   at ObjCRuntime.RegistrarHelper.GetMapEntry(Assembly ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/RegistrarHelper.cs:line 93
   at ObjCRuntime.RegistrarHelper.LookupRegisteredType(Assembly , UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/RegistrarHelper.cs:line 199
   at ObjCRuntime.Class.ResolveToken(Assembly , Module , UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 521
   at ObjCRuntime.Class.ResolveFullTokenReference(UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 449
   at ObjCRuntime.Class.ResolveTokenReference(UInt32 , UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 486
   at ObjCRuntime.Class.ResolveTypeTokenReference(UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 454
   at ObjCRuntime.Class.FindType(NativeHandle , Boolean& ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 423
   at ObjCRuntime.Class.Lookup(IntPtr , Boolean ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 222
   at ObjCRuntime.Class.Lookup(IntPtr ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 213
   at ObjCRuntime.Runtime.GetNSObject[ConsentInformation](IntPtr , IntPtr , RuntimeMethodHandle , Boolean )
   at ObjCRuntime.Runtime.GetNSObject[ConsentInformation](IntPtr , IntPtr , RuntimeMethodHandle )
   at ObjCRuntime.Runtime.GetNSObject[ConsentInformation](IntPtr )
   at Google.UserMessagingPlatform.ConsentInformation.get_SharedInstance()
   at Plugin.MauiMTAdmob.Platforms.iOS.UMPImplementation.InternalInitialiseConsent(Boolean manualRequest, Nullable`1 tagForUnderAgeOfConsent, String testDeviceId, Nullable`1 geography)
   at Plugin.MauiMTAdmob.Platforms.iOS.UMPImplementation..ctor(MauiMTAdmob mauiMTAdmob, String nativeAdsId, String openAdsId, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography, Boolean initialiseConsentAtStartup)
   at Plugin.MauiMTAdmob.MauiMTAdmob.Init(String license, String nativeAdsId, String openAdsId, Boolean enableOpenAds, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography, Boolean initiliseConsentAtStartup)
   at MyApplication.Client.Mobile.AppDelegate..ctor() in /Users/moientajik/Personal/MyApplication/src/frontend/MyApplication.Client.Mobile/Platforms/iOS/AppDelegate.cs:line 14
   at MyApplication.Client.Mobile.AppDelegate..ctor(IntPtr nativeHandle, IManagedRegistrar dummy)
   at MyApplication.Client.Mobile.AppDelegate.__Registrar_Callbacks__.callback_0_MyApplication_Client_Mobile_AppDelegate__ctor(IntPtr pobj, IntPtr sel, Byte* call_super, IntPtr* exception_gchandle)
--- End of stack trace from previous location ---
   at ObjCRuntime.Runtime.ThrowException(IntPtr ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2708
   at UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 64
   at UIKit.UIApplication.Main(String[] , Type , Type ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 96
   at MyApplication.Client.Mobile.Program.Main(String[] args) in /Users/moientajik/Personal/MyApplication/src/frontend/MyApplication.Client.Mobile/Platforms/iOS/Program.cs:line 9
2024-09-03 00:58:32.097 MyApplication.Client.Mobile[42901:4480132] Unhandled managed exception: Could not find the type 'ObjCRuntime.__Registrar__' in the assembly 'Google.UserMessagingPlatform'. (ObjCRuntime.RuntimeException)
   at ObjCRuntime.RegistrarHelper.GetMapEntry(String ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/RegistrarHelper.cs:line 105
   at ObjCRuntime.RegistrarHelper.GetMapEntry(Assembly ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/RegistrarHelper.cs:line 93
   at ObjCRuntime.RegistrarHelper.LookupRegisteredType(Assembly , UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/RegistrarHelper.cs:line 199
   at ObjCRuntime.Class.ResolveToken(Assembly , Module , UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 521
   at ObjCRuntime.Class.ResolveFullTokenReference(UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 449
   at ObjCRuntime.Class.ResolveTokenReference(UInt32 , UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 486
   at ObjCRuntime.Class.ResolveTypeTokenReference(UInt32 ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 454
   at ObjCRuntime.Class.FindType(NativeHandle , Boolean& ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 423
   at ObjCRuntime.Class.Lookup(IntPtr , Boolean ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 222
   at ObjCRuntime.Class.Lookup(IntPtr ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Class.cs:line 213
   at ObjCRuntime.Runtime.GetNSObject[ConsentInformation](IntPtr , IntPtr , RuntimeMethodHandle , Boolean )
   at ObjCRuntime.Runtime.GetNSObject[ConsentInformation](IntPtr , IntPtr , RuntimeMethodHandle )
   at ObjCRuntime.Runtime.GetNSObject[ConsentInformation](IntPtr )
   at Google.UserMessagingPlatform.ConsentInformation.get_SharedInstance()
   at Plugin.MauiMTAdmob.Platforms.iOS.UMPImplementation.InternalInitialiseConsent(Boolean manualRequest, Nullable`1 tagForUnderAgeOfConsent, String testDeviceId, Nullable`1 geography)
   at Plugin.MauiMTAdmob.Platforms.iOS.UMPImplementation..ctor(MauiMTAdmob mauiMTAdmob, String nativeAdsId, String openAdsId, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography, Boolean initialiseConsentAtStartup)
   at Plugin.MauiMTAdmob.MauiMTAdmob.Init(String license, String nativeAdsId, String openAdsId, Boolean enableOpenAds, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography, Boolean initiliseConsentAtStartup)
   at MyApplication.Client.Mobile.AppDelegate..ctor() in /Users/moientajik/Personal/MyApplication/src/frontend/MyApplication.Client.Mobile/Platforms/iOS/AppDelegate.cs:line 14
   at MyApplication.Client.Mobile.AppDelegate..ctor(IntPtr nativeHandle, IManagedRegistrar dummy)
   at MyApplication.Client.Mobile.AppDelegate.__Registrar_Callbacks__.callback_0_MyApplication_Client_Mobile_AppDelegate__ctor(IntPtr pobj, IntPtr sel, Byte* call_super, IntPtr* exception_gchandle)
--- End of stack trace from previous location ---
   at ObjCRuntime.Runtime.ThrowException(IntPtr ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2708
   at UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 64
   at UIKit.UIApplication.Main(String[] , Type , Type ) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 96
   at MyApplication.Client.Mobile.Program.Main(String[] args) in /Users/moientajik/Personal/MyApplication/src/frontend/MyApplication.Client.Mobile/Platforms/iOS/Program.cs:line 9

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0x10711b4f8 - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : mono_dump_native_crash_info
	0x10710255c - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : mono_handle_native_crash
	0x10719104c - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : sigabrt_signal_handler.cold.1
	0x10711ae0c - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : mono_runtime_setup_stat_profiler
	0x222f27afc - /usr/lib/system/libsystem_platform.dylib : <redacted>
	0x222fdcef8 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x1a3c2aad8 - /usr/lib/system/libsystem_c.dylib : abort
	0x106f1fab4 - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : xamarin_find_protocol_wrapper_type
	0x1070318c4 - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : mono_invoke_unhandled_exception_hook
	0x1070e6c6c - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : mono_jit_exec
	0x106f34484 - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : xamarin_main
	0x107166f20 - /private/var/containers/Bundle/Application/E04272FA-B4EA-4389-9440-B2CA2CE53B71/MyApplication.Client.Mobile.app/MyApplication.Client.Mobile : main
	0x1c15dad34 - /usr/lib/dyld : <redacted>

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1ebb2e274):0x1ebb2e264  ff 0f 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._..._..)......
0x1ebb2e274  03 01 00 54 7f 23 03 d5 fd 7b bf a9 fd 03 00 91  ...T.#...{......
0x1ebb2e284  31 ec ff 97 bf 03 00 91 fd 7b c1 a8 ff 0f 5f d6  1........{...._.
0x1ebb2e294  c0 03 5f d6 10 27 80 d2 01 10 00 d4 03 01 00 54  .._..'.........T

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================

Versions:

  • Plugin.MauiMTAdmob: 1.6.2
  • .NET/MAUI: 9.0.100-preview.7.24407.12

MoienTajik avatar Sep 02 '24 23:09 MoienTajik