Interstitial Admob Ads: "Illegalstateexception: Only Fullscreen Activities Can Request Orientation"

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

It seems that upgrading to:

com.google.firebase:firebase-ads:15.0.1

solved this issue for me. I've just tested it on Nexus 5X with 8.1.0 and Interstitial Admob ads work now.

More complete solution:

app's build.gradle:

...

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
...

targetSdkVersion 27

..
}
}

dependencies {
...

implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-ads:15.0.1'

...
}
apply plugin: 'com.google.gms.google-services'

top level build.gradle:

buildscript {
...

dependencies {
...

classpath 'com.google.gms:google-services:3.3.0'

...
}
}

...

android error: IllegalStateException: Only fullscreen opaque activities can request orientation

UPDATE FIND SOLUTION

In android Oreo (API 26) you can not change orientation for Activity that have below line in style

 <item name="android:windowIsTranslucent">true</item>

You have two way for solving this :

  1. You can simply remove above line (or turn it to false) and your app works fine.

  2. Or you can first remove below line from manifest for that activity

    android:screenOrientation="portrait"

Then you must add this line to java file

//android O fix bug orientation

if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

Admob Interstitial orientation is locked to the initial device orientation on startup

I fixed this. In the end it came down to re-requesting the ad on orientation change, and importantly, running that request in the UI thread.

Real Admob Interstitial Ads Not Displaying During Testing of Android App

Use the App Id that you received (can be found on your AdMob dashboard also) in your AndroidManifest.xml instead of ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy.

Replace the "ca-app-pub-3940256099942544/1033173712" with your Ad Unit Id when loading Ads.

Note:

  1. App Id contains a ~ (tilde) in it.
  2. Ad Unit Id contain a / (forward slash).

java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

The problem seems to be happening when your target sdk is 28. So after trying out many options finally this worked.

<activity
android:name=".activities.FilterActivity"
android:theme="@style/Transparent"
android:windowSoftInputMode="stateHidden|adjustResize" />

style:-

<style name="Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>

Note:parent="Theme.AppCompat.Light.NoActionBar" is needed for api 28. Previously had something else at api 26. Was working great but started to give problem at 28.
Hope it helps someone out here.
EDIT: For some only by setting <item name="android:windowIsTranslucent">false</item> and <item name="android:windowIsFloating">false</item>
worked.May be depends upon the way you implement the solution works.In my case it worked by setting them to true.



Related Topics



Leave a reply



Submit