marcojak / MTAdmob

Admob plugin for Xamarin Android and iOS
https://www.xamarinexpert.it/admob-made-easy/
160 stars 26 forks source link

Crash In Release Mode (Android) #98

Closed mistrypragnesh40 closed 2 years ago

mistrypragnesh40 commented 2 years ago

Describe the bug After installing MarcTron.Admob 1.6.9, Application crashing on startup.

To Reproduce Steps to reproduce the behavior:

  1. Install the Admob 1.6.9 Package.
  2. Try to run app in release mode with following configuraiton
    1. Dex Compiler d8
    2. Code Shrinker r8
  3. Run the application in release mode.
  4. App Will Crash on Start Up.

Further info: I am using target framework for compiling is : Android 12.0 (S)

Expected behavior App Should not crash.

Roccosco commented 2 years ago

I also have this problem.

marcojak commented 2 years ago

The problem is caused by R8 that removes some needed classes.

To solve the error, in the Android project add the file ProGuard.cfg and set its build action as ProguardConfiguration. Inside the empty file add these two lines:

-keep class com.google.android.gms.ads.MobileAdsInitProvider -keep class androidx.work.impl.WorkManagerInitializer

I've tested it with the SampleMTAdmob project and it works fine.

I'm closing the issue now but if you still have problems, feel free to reopen it.

gsgou commented 2 years ago

I was still getting crashes on Android devices. Following proguard config fixed my issues: -keep public class com.google.android.gms.ads.* { public ; } -keep public class com.google.ads.* { public ; } -keep class androidx.work.impl.WorkManagerInitializer