Admob (firebase-ads:20.4.0) *NOT* compatible with Android 12

658 views
Skip to first unread message

rootBerz LLC

unread,
Nov 2, 2021, 10:29:52 AM11/2/21
to Google Mobile Ads SDK Developers
I tested this several times on my Pixel 3a XL running Android 12.

STEPS TO REPRODUCE:

Create a new Android Studio project with an Empty Activity. Android Studio will create its own Manifest and Gradle, etc...

Add to Manifest:
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>


GRADLE (all below is default, but see red item below):
plugins {
    id 'com.android.application'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.testing.admobissuee"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.google.firebase:firebase-ads:20.4.0'   // THE PROJECT WILL DEPLOY PROPERLY TO YOUR DEVICE IF THIS LINE IS REMOVED. App will crash if this line is included.
}

*************** Deploy app to a device running Android 12. 

ERROR will be:
2021-11-01 11:50:56.416 1642-1709/com.testing.admobissuee E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
    Process: com.testing.admobissuee, PID: 1642
    java.lang.IllegalArgumentException: com.testing.admobissuee: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
        at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
        at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
        at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)

Mobile Ads SDK Forum Advisor

unread,
Nov 3, 2021, 1:16:57 AM11/3/21
to rootb...@gmail.com, google-adm...@googlegroups.com

Hello RootBerz,

Thank you for reaching out to us.

Since you mentioned that you're using the Android 12 in this, as per the android requirements, WorkManager Version 2.7.0 is required for apps targeting Android 12 (S). I would recommend including the "implementation 'androidx.work:work-runtime:2.7.0'" in your gradle file to be able to create your project.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2QH4xN:ref

rootBerz LLC

unread,
Nov 3, 2021, 6:33:52 PM11/3/21
to Google Mobile Ads SDK Developers
Thanks for responding.

You are right, adding the additional library, even though I am NOT using anything in that library, will allow com.google.firebase:firebase-ads:20.4.0 to work properly.

Do you know if there will be an update to the firebase-ads library that will allow me to remove the unused work-runtime library?

I believe there is a call in the firebase-ads library that is using PendingIntent, but not including the new requirement of either of these:  FLAG_IMMUTABLE or FLAG_MUTABLE


Thank you!

Mobile Ads SDK Forum Advisor

unread,
Nov 4, 2021, 1:09:16 AM11/4/21
to rootb...@gmail.com, google-adm...@googlegroups.com

Hello Rootberz,

Thank you for your response.

With regard to your question for the update in firebase-ads library, we recommend reaching out to the Firebase support team with regards to this.

Reply all
Reply to author
Forward
0 new messages