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

前端 未结 7 803
故里飘歌
故里飘歌 2020-11-28 22:26

Background

I have an app with Admob SDK used in it, to show Interstitial ads (full screen ads).

Reccently Google has updated the SDK, along with many other

7条回答
  •  难免孤独
    2020-11-28 22:29

    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

提交回复
热议问题