Debug build runs fine, but release builds throw exception

Jesse Knott 686 Reputation points
2021-09-30T19:20:54.96+00:00

I'm having a hard time troubleshooting this. Perhaps someone can tell me what's wrong by this error?

When I run a Debug build it compiles and runs on the emulator just fine, but if I try to run a release build, it throws this error?
My build environment is a bit odd, I am building both Paid and free versions of my app from the same code base.
As a result I have an alternate FreeEditionAndroidManifest.xml file, that has an appId I created for the free edition of the app. The paid version has an addId associated with that version but ads are never shown.
For the ads themselves, I am only using the adIds associated with the Free edition of the app since the paid never shows ads anyway.

Neither the paid nor the free builds will run release versions. I can only get the log output from the DDMS since it's a release build, and it seems that it's not entirely useful info...

Is this related to the emulator not allowing AdMob to run in production releases?

java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider"
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,741 Reputation points Microsoft Vendor
    2021-10-01T05:35:24.663+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Which Linker and code shrinker did you set?

    Please set Linker to none, then release your application, if it works. If the Linker set to None, then you can release your application, If this issue disappear, because Linker are excluding com.google.android.gms.ads.MobileAdsInitProvider

    And if code shrinker to ‘R8’, please enable the ProGuard. Next, you can either let the Xamarin.Android build process use a default ProGuard configuration file, or you can create your own custom configuration file for ProGuard to use.

    Add follow code to your custom configuration file for ProGuard.

       \-keep public class com.google.android.gms.ads.MobileAdsInitProvider  
    

    If you want to set Linker option to Sdk Assemblies Only. You need to instruct it to keep the code that shouldn't be stripped out. You can see this thread

    If you want to keep

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful