requestFeature() must be called before adding content (AdMob)

241 views
Skip to first unread message

Orlando Yanson Jr.

unread,
Jun 27, 2016, 4:39:08 AM6/27/16
to Google Mobile Ads SDK Developers
I got this error and I don't know what causes this. Can you help me wit this error?

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.app/com.google.android.gms.ads.AdActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) at android.app.ActivityThread.access$900(ActivityThread.java:172) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5832) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:352) at android.app.Activity.requestWindowFeature(Activity.java:3759) at com.google.android.gms.ads.internal.overlay.ab.a(:com.google.android.gms.DynamiteModulesA:279) at com.google.android.gms.ads.internal.overlay.client.c.onTransact(:com.google.android.gms.DynamiteModulesA:58) at android.os.Binder.transact(Binder.java:380) at com.google.android.gms.internal.zzfk$zza$zza.onCreate(Unknown Source) at com.google.android.gms.ads.AdActivity.onCreate(Unknown Source) at android.app.Activity.performCreate(Activity.java:6221) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)  at android.app.ActivityThread.access$900(ActivityThread.java:172)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5832)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) *

here's my xml code

 <com.google.android.gms.ads.AdView
   
android:id="@+id/ad_view"
   
android:layout_width="match_parent"
   
android:layout_height="wrap_content"
   
android:layout_centerHorizontal="true"
   
android:layout_alignParentBottom="true"
   
ads:adSize="BANNER"
   
ads:adUnitId="@string/banner_ad_unit_id" />
and declared it on onFinishInflate of my custom view

@Override
protected void onFinishInflate() {
   
super.onFinishInflate();
   mAdView
= (AdView) findViewById(R.id.ad_view);
   
AdRequest adRequest = new AdRequest.Builder()
           
.build();
   adView
.loadAd(adRequest);
}



Vu Chau (Mobile Ads SDK Team)

unread,
Jun 27, 2016, 3:09:32 PM6/27/16
to Google Mobile Ads SDK Developers
Hi Orlando,

I see there was an occurrence of this bug in 2014, and there already was a fix for it.  If you are able to reproduce this crash locally again, we'd like to obtain some more information:
  1. Do you have a sample app that triggers this crash? Are you able to reproduce it in our own sample?
    • If so, please send us a zipped project, or even a live app.
  2. What's the Google Play services version you are using to compile the app, and what is its version on your physical device?
    • If you're using Firebase, which dependency are you using?
  3. On which device / Android API version did you see this crash?
Vu Chau
Mobile Ads SDK Team
Reply all
Reply to author
Forward
0 new messages