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

Invalid type MarcTron.Plugin.Services.RewardService when updating to Xamarin.Google.iOS.MobileAds 8.13.0 #100

Open
jthun opened this issue Mar 10, 2022 · 3 comments

Comments

@jthun
Copy link

jthun commented Mar 10, 2022

Describe the bug
Hi! I love the plugin! But when updating Xamarin.Google.iOS.MobileAds to 8.13.0 from 7.66.0, it crashes when launching the iOS app in a simulator, and on a real device it does not compile.

Simulator Launch:

System.TypeLoadException: Invalid type MarcTron.Plugin.Services.RewardService for instance field MarcTron.Plugin.MTAdmobImplementation:rewardService
  at System.Lazy`1[T].PublicationOnlyViaFactory (System.LazyHelper initializer) [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:382 
  at System.Lazy`1[T].CreateValue () [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:419 
  at System.Lazy`1[T].get_Value () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:509 
  at MarcTron.Plugin.CrossMTAdmob.get_Current () [0x00000] in <a1f1d80e99184596a232d1ec3a284d13>:0 
  at MyApp.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary opti
ons) [0x00044] in C:\Users\myusername\source\repos\MyAppName\MyApp\MyApp.iOS\AppDelegate.cs:118 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:83 
  at MyApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\myusername\source\repos\MyAppName\MyApp\MyApp.iOS\Main.cs:27
2022-03-10 10:32:25.085471+0100 MyApp.iOS[33601:3899831] Unhandled managed exception: Invalid type MarcTron.Plugin.Services.RewardService for instance field MarcTron.Plugin.MTAdmobImplementation:rewardService (System.TypeLoadException)
  at System.Lazy`1[T].PublicationOnlyViaFactory (System.LazyHelper initializer) [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:382 
  at System.Lazy`1[T].CreateValue () [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:419 
  at System.Lazy`1[T].get_Value () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:509 
  at MarcTron.Plugin.CrossMTAdmob.get_Current () [0x00000] in <a1f1d80e99184596a232d1ec3a284d13>:0 
  at MyApp.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDiction
ary options) [0x00044] in C:\Users\myusername\source\repos\MyAppName\MyApp\MyApp.iOS\AppDelegate.cs:118 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:83 
  at MyApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\myusername\source\repos\MyAppName\MyApp\MyApp.iOS\Main.cs:27

It happens in AppDelegate.cs at
CrossMTAdmob.Current.AdsId = "ca-app-pub-<theid>";

Device Compile:

1>  AOT Compilation exited with code 1, command:
1>  MONO_PATH='/Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/3-Build' /Library/Frameworks/Xamarin.iOS.framework/Versions/15.6.0.3/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt -O=-float32 "--aot=mtriple=arm64-ios,data-outfile=/Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/arm64/Plugin.MtAdmob.aotdata.arm64,static,asmonly,direct-icalls,interp,full,soft-debug,dwarfdebug,no-direct-calls,outfile=/Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/arm64/Plugin.MtAdmob.dll.s" "/Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/3-Build/Plugin.MtAdmob.dll"
1>  Mono Ahead of Time compiler - compiling assembly /Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/3-Build/Plugin.MtAdmob.dll
1>  AOTID 4633FCE3-F48D-4764-BBEF-6E521660CCEA
1>  Failed to load method 0x600004f from '/Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/3-Build/Plugin.MtAdmob.dll' due to Could not resolve type with token 01000023 from typeref (expected class 'Google.MobileAds.RewardBasedVideoAdDelegate' in assembly 'Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Google.MobileAds, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Google.MobileAds.RewardBasedVideoAdDelegate member:(null).
1>  Run with MONO_LOG_LEVEL=debug for more information.
1>  AOT of image /Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/3-Build/Plugin.MtAdmob.dll failed.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(255,3): error MT3001: Could not AOT the assembly '/Users/myusername/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/ef58f5b1f5864c4b0356f5feb837a5ef392411dd92471ed788c20782a7e22379/obj/iPhone/Debug DEV/mtouch-cache/3-Build/Plugin.MtAdmob.dll'

To Reproduce
Steps to reproduce the behavior:

  1. Update Xamarin.Google.iOS.MobileAds to 8.13.0 from 7.66.0
  2. Launch the iOS app in a simulator or try to compile with a real iOS device.

Expected behavior
No crash, as when using Xamarin.Google.iOS.MobileAds 7.66.0.

Smartphone (please complete the following information):

  • Devices: iPhone 13 Simulator with iOS 15.2 and real iPhone 12 Pro with iOS 15.3.1

Additional context
Xamarin Forms 5.0.0.2337
VS 2022 17.1.1

@marcojak
Copy link
Owner

Hi,
I'm currently updating the plugin to support Xamarin.Google.iOS.MobileAd 9.13.0.

It seems that there are few incompatibilities so I'll have to fix them and I'll release a new version soon.
Meanwhile I'd suggest you to stay with version 7.66.

Cheers,
Marco

@jthun
Copy link
Author

jthun commented Mar 11, 2022

Awesome, looking forward to the new update! Many thanks!

@mxstudios
Copy link

Maybe you could update the readme to say this until you get it updated to work with 8.3.0 +. Took a little while of debugging before I can here and found this. Anyone using the plug in after 8.12 was released will be having issues.

Thanks! Hoping this will work out for my app.

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

3 participants