willowtreeapps / Hyperion-Android

App Debugging & Inspection Tool for Android
MIT License
1.95k stars 145 forks source link

Hyperion Core is Incompatible with requestWindowFeature() #144

Open GPryan opened 6 years ago

GPryan commented 6 years ago

We have an activity with the following onCreate() implementation:

protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);

  // And more
}

and the following manifest declaration:

<activity
    android:name="ExampleActivity"
    android:launchMode="singleTop"
    android:theme="@android:style/Theme.Holo.Light.Dialog">
</activity>

However, when including debugImplementation 'com.willowtreeapps.hyperion:hyperion-core:0.9.24', we get the following crash upon the activity starting.

java.lang.RuntimeException: Unable to start activity ComponentInfo{net.grandpad.zebra/net.grandpad.zebra.call.IncomingCallActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.access$900(ActivityThread.java:150)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
        at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:317)
        at android.app.Activity.requestWindowFeature(Activity.java:3690)
        at net.grandpad.zebra.call.IncomingCallActivity.onCreate(IncomingCallActivity.java:56)
        at android.app.Activity.performCreate(Activity.java:6285)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.access$900(ActivityThread.java:150) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Any help or fix would be great. Keep up the great work. Thanks!

GPryan commented 6 years ago

I'll note, we got around this by using Theme.Holo.Light.Dialog.NoActionBar instead of requestWindowFeature(Window.FEATURE_NO_TITLE), so this is no longer an issue for us. Still could be good to fix though :)

mezpahlan commented 5 years ago

We have a similar problem with Hyperion and android.util.AndroidRuntimeException: requestFeature() must be called before adding content.

In our case we have a third party library creating a fullscreen activity upon receiving a broadcast (for marketing purposes). When this broadcast is received the third party library attempts to spawn a full screen activity but instead we see this crash.

As others have commented this is only an issue in builds that have Hyperion installed or the no-op version active. However, what's odd here is that we notice this crash on Android versions 5 and below.

It differs slightly from @GPryan 's issue in that we aren't setting requestWindowFeature(Window.FEATURE_NO_TITLE) (that's happening via the 3rd party library) but otherwise it appears the same.