Hi,
I’ve been using custom assemblies through my project to make everything more modular and I had to in the past create assemblies of plugins as well. I tried to do the same for AdMob but I get the error below.
NullReferenceException: Object reference not set to an instance of an object
GoogleMobileAds.Api.MobileAds.GetMobileAdsClient () (at Assets/GoogleMobileAds/Api/MobileAds.cs:50)
GoogleMobileAds.Api.MobileAds..cctor () (at Assets/GoogleMobileAds/Api/MobileAds.cs:24)
Rethrow as TypeInitializationException: The type initializer for 'GoogleMobileAds.Api.MobileAds' threw an exception.
AdMobInitialize.Awake () (at Assets/BasicMobile/Scripts/Ads/AdMobInitialize.cs:20)
Deleting all the assemblies resolves the issue, but I was wondering if there is a better way.
To replicate the problem:
- Empty Unity project
- Import AdMob
- Create an assembly for the adMob
- Create a script Like so:
string appId = "myAppID" //Here you put the actual ID, or a test ID
MobileAds.Initialize(appId);
- Create custom assembly for the script and reference the AdMob assembly to it.
I would appreciate some help. Am I using assemblies wrong?