Bug: getting exception for native ads: "AndroidRuntimeException: requestFeature() must be called before adding content"

282 views
Skip to first unread message

Liran Barsisa

unread,
Jun 6, 2024, 4:59:28 AM6/6/24
to Google Mobile Ads SDK Developers
    implementation "com.google.android.gms:play-services-ads:23.1.0"

I don't know the steps. I don't know what's causing it.
I only know that it's related to ads because of the stack-trace, and that it seems it happened in the past.

Affected Android versions: from 5 to 10 (including).
Affected devices: plenty:
  1. Symphony Teleca: GN5001S
  2. Huawei: Honor 7i
  3. Alps: I13 Pro Max, MAX10_Pro
  4. Samsung: Galaxy Note3, Galaxy S4
  5. Other: Symphony Teleca, M3note, Lenovo Mobile, Gionee

logs:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lb.app_manager/com.google.android.gms.ads.AdActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
       at android.app.ActivityThread.access$900(ActivityThread.java:177)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5951)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by android.util.AndroidRuntimeException: requestFeature() must be called before adding content
       at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:359)
       at android.app.Activity.requestWindowFeature(Activity.java:3785)
       at com.google.android.gms.ads.internal.overlay.x.d(:com.google.android.gms.policy_ads_fdr_dynamite@241199802@241199801000.618989241.618989241:22)
       at com.google.android.gms.ads.internal.overlay.client.a.bS(:com.google.android.gms.policy_ads_fdr_dynamite@241199802@241199801000.618989241.618989241:196)
       at m.amg.onTransact(:com.google.android.gms.policy_ads_fdr_dynamite@241199802@241199801000.618989241.618989241:21)
       at android.os.Binder.transact(Binder.java:380)
       at com.google.android.gms.internal.ads.zzazo.zzdc(com.google.android.gms:play-services-ads-base@@23.1.0:2)
       at com.google.android.gms.internal.ads.zzbun.zzl(com.google.android.gms:play-services-ads-lite@@23.1.0:3)
       at com.google.android.gms.ads.AdActivity.onCreate(com.google.android.gms:play-services-ads-lite@@23.1.0:3)
       at android.app.Activity.performCreate(Activity.java:6289)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
       at android.app.ActivityThread.access$900(ActivityThread.java:177)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5951)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
chrome_2024-06-06_11-58-43.mp4

Mobile Ads SDK Forum Advisor

unread,
Jun 6, 2024, 11:19:54 AM6/6/24
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi Liran,

Kindly be advised that we are not able to access the Crashlytics link you have provided to us. Please provide access to the document.

Could you confirm whether the mentioned issue is reproducible in our Google Sample Project. If so, please provide the following information privately so that we can gain full visibility of your implementation:

  • app ID
  • ad unit ID
  • Full stack trace
  • Sample project reproducing the issue

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files to us via reply to author option or using the steps below:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002tJES7QAO&entry.80707362=00238662

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

This message is in relation to case "ref:!00D1U01174p.!5004Q02tJES7:ref" (ADR-00238662)

Thanks,
 
Google Logo Mobile Ads SDK Team


Liran Barsisa

unread,
Jun 6, 2024, 11:45:52 AM6/6/24
to Google Mobile Ads SDK Developers
I've provided you a video to what's on the link.
As for access, tell me how to provide you access to it.

About a sample project, of course I can't give the users who got this crash the sample project. I don't even know how to contact them. 
It's probably against the rules of Crashlytics too, to be able to identify the user and contact him...
These days are sadly over many years ago.
There are privacy concerns these days.

Think of better ways to investigate and fix this issue.
When you have a normal app, you won't have this weird solution offered here either. Doesn't make sense to reach someone on Crashlytics...  
You'd take a look at the Crashlytics logs, and match them with your own code, to figure out the origin of the issue and fix it there.

You can't suggest such a solution anymore. You should remove this template of offering it for Crahslytics logs.

Liran Barsisa

unread,
Jun 6, 2024, 4:21:43 PM6/6/24
to Google Mobile Ads SDK Developers
Attached video of recent 30 days too, which shows it happens on more devices


chrome_2024-06-06_23-09-12.mp4

Mobile Ads SDK Forum Advisor

unread,
Jun 6, 2024, 6:05:27 PM6/6/24
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi Liran,

I'm afraid that we'll need detailed debug information from a device where it's observed in order to actually make any progress in diagnosing this. The only way for us to investigate further is by creating a project where the issue is reproducible.

As requested earlier, kindly provide your app ID and ad unit ID via reply to author option to do further investigation.

Liran Barsisa

unread,
Jun 6, 2024, 6:19:10 PM6/6/24
to Google Mobile Ads SDK Developers
You can't just ignore hundreds of crash reports via Crashlytics, just because you can't reproduce on a new project. 
The stack trace doesn't even mention code of the app.
It's purely in the SDK of Admob. 
I already said that I use it for native ads. There is nothing else I can give you. 
Your request doesn't make sense. You can't tell me to have some remote control of random users that this was reported on via Crashlytics. 
That's not the "only way" at all to solve issues. You don't do it on any app. Ever.
You will get almost 0 response from users even if you had such an ability.

Would "reply to author" mean it's not public for all to see here?
How would it even help to see it?

Mobile Ads SDK Forum Advisor

unread,
Jun 10, 2024, 12:26:12 AM6/10/24
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi,

app ID and ad unit ID are sensitive information so requested to share via "Reply to author" option. Upon sharing the required information we would be checking the account related information and share all these details with wider team for further investigation.

Mobile Ads SDK Forum Advisor

unread,
Sep 9, 2024, 9:18:28 AM9/9/24
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi, 

Thank you for getting back to us..

I will check with our team regarding your query and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated. 

Lisitso

unread,
Nov 2, 2025, 6:20:47 AM (3 days ago) Nov 2
to Google Mobile Ads SDK Developers
Same problem here. Any update? Mobile Ads SDK team disappears if no one pings...

L.

Mobile Ads SDK Forum Advisor

unread,
Nov 3, 2025, 2:40:26 PM (2 days ago) Nov 3
to andre...@gmail.com, google-adm...@googlegroups.com
Hello there,
 
 
Thank you for bumping this thread.
 
Root cause
Looking at the stack trace provided, the root cause is an android.util.AndroidRuntimeException with the message: requestFeature() must be called before adding content. This error happens when an Android Activity attempts to call a window-related method like requestWindowFeature() or setContentView() after the system has already started drawing the content.
 
The error itself occurs within a GMA SDK-related component (com.google.android.gms.ads.AdActivity and internal classes like com.google.android.gms.ads.internal.overlay).
However, the immediate cause is likely an incorrect theme applied to the AdActivity in the AndroidManifest.xml file.
 
 
Potential solution
You can resolve this crash by ensuring they have correctly defined the AdActivity in their AndroidManifest.xml file with an appropriate theme.
The AdActivity declaration in the application's manifest should be present and should not use a theme that forces content to be added too early (like a standard Theme.AppCompat theme).
 
For example:
```
<activity
    android:name="com.google.android.gms.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    android:theme="@android:style/Theme.Translucent" 
    />
```
 
 

Thanks,
 
Google Logo
Joshua
Mobile Ads SDK Team


Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-11-03 19:39:26Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02tJES7:ref" (ADR-00238662)



Süleyman Temir

unread,
5:19 AM (11 hours ago) 5:19 AM
to Lisitso, Google Mobile Ads SDK Developers

2 Kas 2025 Paz 14:20 tarihinde Lisitso <andre...@gmail.com> şunu yazdı:
--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-admob-ads-sdk/dcaa2ff3-88a8-4135-942c-666839c3b7een%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages