androidflutteradmobadsfirebase-admob

Ads are not showing up in release mode


Ads not showing up in release mode

i want to try the solution mentioned here but i dont know how to

when the app is signed in debug it shows ads , but not in release mode


Solution

  • Create a file called proguard-rules.pro in your android/app directory.

    Add this line of code to it:

     -keep class io.flutter.app.** { *; }
     -keep class io.flutter.plugin.** { *; }
     -keep class io.flutter.util.** { *; }
     -keep class io.flutter.view.** { *; }
     -keep class io.flutter.** { *; }
     -keep class io.flutter.plugins.** { *; }
     -keep class com.google.firebase.** { *; }
     -keep class com.shatsy.** { *; }
    

    The most important being: -keep class com.google.firebase.** { *; } and -keep class com.shatsy.** { *; }

    Now in your app level build.gradle file, add this to your buildType:

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    

    So that your buildType folder looks something like this:

    buildTypes {
            release {
                minifyEnabled true
                shrinkResources true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.debug
            }
        }
    

    Then run flutter build apk --buildTypeName

    Example:

    flutter build apk --release
    

    A quicker solution is to add minifyEnabled false to your release buildType in you app level build.gradle

    EXPLANATION: Proguard is probably blocking your app from using the firebase_ads library. That's probably why your app runs in debug mode, but not after building the apk.

    Try it, and see if it works.