Build striping breaks Google Ads Plugin

Hi all,

I have the problems with Google Ads Plugin when build with stripping enabled. I tried to create a file link.xml as below but it doesn’t work. Anybody please help.

<linker>
    <!-- This fixes GameSparks 'ERROR: The authentication or decryption has failed' errors when stripping is enabled -->
     <assembly fullname="GoogleMobileAds">
         <type fullname="GoogleMobileAds.*" preserve="all"/>                          
     </assembly>
    <assembly fullname="PlayServicesResolver">
         <type fullname="PlayServicesResolver.*" preserve="all"/>                          
     </assembly>
   
</linker>

Below is a solution that’s available online. Perhaps it applies to the error you’re experiencing. It would be convenient if this issue could be addressed using a link.xml file. Changing the stripping level to “Low” fixed it in my project. Also, some users found they were opening the Xcode project file instead of the Xcode workspace file.


"NullReferenceException: Object reference not set to an instance of an object
at GoogleMobileAds.Api.MobileAds.GetMobileAdsClient ()…

It looks like Unity was stripping the code out for Reflection. Documented here - Unity - Manual: Managed code stripping

To solve this issue, one can either:

Add the following lines in GoogleMobileAdsClientFactory.cs
using UnityEngine.Scripting;
[assembly: Preserve]

OR

Change the “Managed Stripping Level” to Low or less.
I hope this helps.”