Interstitial Admob ads: “IllegalStateException: Only fullscreen activities can request orientation”

EDIT

Now a newer admob version is available.
I confirm that using the latest releases (15.0.1 or newer) the issue doesn’t appear anymore, so you can use the latest version of Admob

com.google.firebase:firebase-ads:17.1.2

setting the target version to the latest, if you have used the workaround previously suggested.

———————————————————-

Set the target to Android API Level to 26 to fix the issue, waiting for Admob update

In build.gradle

targetSdkVersion 26

if targetSdkVersion is >=27 ( > android.os.Build.VERSION_CODES.Othat is 26) you get this error, they have changed ActivityRecord in latest Android version adding this:

void setRequestedOrientation(int requestedOrientation) {
        if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen
                && appInfo.targetSdkVersion > O) {
            throw new IllegalStateException("Only fullscreen activities can request orientation");
        ....
        }

The change has been introduced in this commit

Prevent non-fullscreen activities from influencing orientation This
changelist enforces that activities targeting O and beyond can only
specify an orientation if they are fullscreen.

and probably in admob lib have messed some check

Leave a Comment