Xamarin: Release Mode Crashing Constantly (Android)

I’ve got a Xamarin application that I’ve been more or less been developing and testing in debug mode, when I try to change it to release mode; the application crashes on the splash screen everytime when I try to deploy it to the emulator or physical android device.

Everything works perfect in debug mode even when deploying to a device, just when I try to deploy in release mode. Unsurprisingly, the app on the google play simply crashes when people try to install and run it as well.

I’ve added the INTERNET permission to the Android Manifest as I’ve seen this also as a common cause, and all other permissions necessary. But what’s SO DIFFERENT with release mode that it just crashes.

Please help.

Error       error: cannot find symbol
        com.google.android.gms.ads.OnPaidEventListener
  symbol:   class OnPaidEventListener
  location: package com.google.android.gms.ads  FlowDynamics.Mobile.Core.Android    C:SourceFlowDynamicsMobileFlowDynamics.Mobile.Core.AndroidobjRelease100androidsrcmonocomgoogleandroidgmsadsOnPaidEventListenerImplementor.java   8   

Error       error: cannot find symbol
    public void onPaidEvent (com.google.android.gms.ads.AdValue p0)
  symbol:   class AdValue
  location: package com.google.android.gms.ads  FlowDynamics.Mobile.Core.Android    C:SourceFlowDynamicsMobileFlowDynamics.Mobile.Core.AndroidobjRelease100androidsrcmonocomgoogleandroidgmsadsOnPaidEventListenerImplementor.java   28  

Error       error: cannot find symbol
    private native void n_onPaidEvent (com.google.android.gms.ads.AdValue p0);
  symbol:   class AdValue
  location: package com.google.android.gms.ads  FlowDynamics.Mobile.Core.Android    C:SourceFlowDynamicsMobileFlowDynamics.Mobile.Core.AndroidobjRelease100androidsrcmonocomgoogleandroidgmsadsOnPaidEventListenerImplementor.java   33  



I've also managed to get this error from the device log when trying to deploy to a physical device:


03-31 23:41:18.578  Google Pixel XL Error   11565   **AndroidRuntime    java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider"** on path: DexPathList[[zip file "/data/app/com.upsilondynamics.flowassist-hHH-Zhx6-8g-jnQjoHz5Zw==/base.apk"],nativeLibraryDirectories=[/data/app/com.upsilondynamics.flowassist-hHH-Zhx6-8g-jnQjoHz5Zw==/lib/arm64, /data/app/com.upsilondynamics.flowassist-hHH-Zhx6-8g-jnQjoHz5Zw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/product/lib64]]
    at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
    at android.app.ActivityThread.access$1300(ActivityThread.java:219)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

I believe there are a bunch of issues related to Google Ad Mobs

Configuration Manager Settings

Configuration Settings

Android Project Settings

enter image description here

enter image description here

enter image description here

enter image description here

And finally, the Nuget packages I think are responsible for all this. When I try to upgrade them to the latest, I just get a Java exited with -1 error, so round and round we go; nothing is working with release mode.

enter image description here

Answer

So I managed to figure this out, make sure in the Build settings you disable Optimize code:

Build Settings

Also, ensure you turn off Multi-Dex:

Android Options