插页式Admob广告:“ IllegalStateException:只有全屏活动可以请求定向” [英] Interstitial Admob ads: "IllegalStateException: Only fullscreen activities can request orientation"

查看:116
本文介绍了插页式Admob广告:“ IllegalStateException:只有全屏活动可以请求定向”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用了Admob SDK的应用来显示插页式广告(全屏广告)。

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

最近,Google已更新了SDK,以及许多其他东西(构建工具,gradle插件,IDE等),包括admob(firebase广告)。

Reccently Google has updated the SDK, along with many other things (build tools, gradle plugin, IDE, etc...), including admob (firebase ads).

compile 'com.google.firebase:firebase-ads:11.4.2'



问题



更新后,我注意到,只要该应用尝试展示插页式广告,它就会崩溃。

The problem

After updating, I noticed that whenever the app tries to show an Interstitial ad, it crashes.

崩溃日志如下:

10-28 14:01:01.394 4523-4523/... I/Ads: Ad opening.
10-28 14:01:01.400 1606-2154/? E/ActivityManager: Activity Manager Crash. UID:10080 PID:4523 TRANS:63
                                                  java.lang.IllegalStateException: Only fullscreen activities can request orientation
                                                      at com.android.server.am.ActivityRecord.setRequestedOrientation(ActivityRecord.java:2189)
                                                      at com.android.server.am.ActivityManagerService.setRequestedOrientation(ActivityManagerService.java:4975)
                                                      at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:1101)
                                                      at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2927)
                                                      at android.os.Binder.execTransact(Binder.java:697)


10-28 14:01:01.403 4523-4523/... D/AndroidRuntime: Shutting down VM
10-28 14:01:01.406 4523-4523/... E/AndroidRuntime: FATAL EXCEPTION: main

java.lang.RuntimeException: Unable to start activity ComponentInfo{.../com.google.android.gms.ads.AdActivity}: java.lang.IllegalStateException: Only fullscreen activities can request orientation

事情以前还不错。现在,我不确定是什么原因引起的。

Thing is that it worked fine before. Now I'm not sure what causes it to occur.

在网络上搜索时,我没有看到任何有关只有全屏活动才能请求定向的信息。

Searching the web, I didn't see anything that talks about "Only fullscreen activities can request orientation" .

清单上的内容有些陈旧,可能不再需要了:

What I had in the manifest, is something a bit old, that might not be needed anymore:

    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent"/>

我说可能不需要,因为即使在本教程中我也看不到它,尽管我记得我曾经做过:

I say it's probably not needed, because i can't see it anymore in the tutorials, even though I remember I did in the past:

  • https://developers.google.com/admob/android/quick-start
  • https://developers.google.com/admob/android/interstitial

  1. 我尝试删除清单条目。还是同样的问题。

  1. I tried to remove the manifest entry. Still same issue.

我试图通过强制将主题设置为 @android:style / Theme.Translucent.NoTitleBar.Fullscreen,但没帮助。

I tried to set the theme to be "@android:style/Theme.Translucent.NoTitleBar.Fullscreen" by force, but it also didn't help.

我什至以为这可能是因为我当前拥有Android 8.1,但是当我尝试从Play商店使用该应用时,注意到它工作正常,没有崩溃。

I even thought that it might be because I currently have Android 8.1, but when I tried using the app from the play store, I noticed it worked just fine, without crashes.

我试图回到admob的11.2.2版本并使用gradle v 2.3.3,

I tried to go back to as far as version 11.2.2 of admob and use gradle v 2.3.3 , but it also didn't help.

在使用Android 7.0的模拟器上进行尝试时,它可以与最新版本的一切正常工作,并且可以删除整个清单活动标签。

When trying on an emulator with Android 7.0 , it worked fine with latest versions of everything, and removal of the whole manifest activity tag.

我尝试在gradle文件中使用它,而不是我以前使用的文件:

I tried to use this in gradle file, instead of what I used :

compile'c​​om.google.android.gms:play-services-ads:11.4.2'

compile 'com.google.android.gms:play-services-ads:11.4.2'

仍然崩溃


  1. 在我的设备(带有Android 8.1的Nexus 5x)上,并没有在模拟器上崩溃。我尝试在以下位置运行该应用模拟器与Android 8.1结合使用,并且崩溃的情况与实际设备相同。

  1. Finally, I tried to run the app on emulator with Android 8.1, and it crashed just as on the real device.

已向Google Admob小组以及 Android问题跟踪器 。我希望他们会回答我。

Reported about this to Google Admob team, as well as Android issue tracker. I hope they will answer me about this.



问题



这个问题可能是什么原因?

The questions

What could be the cause to this issue?

是因为Android 8.1吗?如果是这样,那么较旧版本的应用程序如何正常运行?我试图将许多版本恢复为旧版本,但仍然崩溃。

Is it because of Android 8.1 ? If so, how come the older version of the app worked fine? I tried to revert there a lot of versions to old ones, yet it still crashed.

而且,最重要的是,我该如何解决?

And, most importantly, how can I solve it?

推荐答案

似乎要升级到:

com.google.firebase:firebase-ads:15.0.1

为我解决了这个问题。我刚刚在Nexus 5X上使用8.1.0进行了测试,并且Interstitial Admob广告现在可以正常工作。

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

更完整的解决方案:

app的build.gradle:

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'

顶级build.gradle:

top level build.gradle:

buildscript {
    ...

    dependencies {
        ...

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

        ...
    }
}

...

这篇关于插页式Admob广告:“ IllegalStateException:只有全屏活动可以请求定向”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆