AndroidRuntimeException: requestFeature () must be called before adding exclusive content in Honeycomb 3.1 - 3.2.1

After the last update, my application had the following problem:

java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package/my.package.MyMainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1818) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834) at android.app.ActivityThread.access$500(ActivityThread.java:122) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1027) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:132) at android.app.ActivityThread.main(ActivityThread.java:4126) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:491) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) at dalvik.system.NativeStart.main(Native Method) Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:214) at android.support.v7.app.ActionBarActivityDelegateHC.onCreate(ActionBarActivityDelegateHC.java:38) at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) at my.package.MyBaseActivity.onCreate(MyBaseActivity.java:68) at my.package.MyApiServiceActivity.onCreate(MyApiServiceActivity.java:51) at my.package.MyActivity.onCreate(MyActivity.java:88) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1782) ... 11 more 

However, I never call requestWindowFeature or the like. There are also no dialogs. The report itself comes from BugSense, I have never had this problem. This is a fairly popular application, and the problem is exclusive to Android Honeycomb : 3.2, 3.2.1 and 3.1. This did not happen in the previous version of the application. The only change to the onCreate function since the update is the fact that I switched from ActionBarSherlock to ActionBarCompat .

Has anyone noticed this problem and / or had any ideas on how to overcome this problem?

EDIT: I am adding a source link for ActionBarActivityDelegateHC from package v7 where the trace of the alarm stack begins (called ...). There is a requestFeature request, but it is called correctly, even before super.onCreate .

I use Gradle to import the package: compile 'com.android.support:appcompat-v7:18.0.+'

+6
source share
1 answer

So it seems that the solution from @shomeser (comments on the question) is a way to go on time.

There are two ways to compromise:

  • If you do not have different layouts for landscape and portrait, you can turn off orientation changes (in AndroidManifest: android:configChanges="screenSize|orientation" )
  • If you have some processing when changing the orientation and cannot use "configChanges", you can block the orientation (in onCreate )
  if (Build.VERSION.SDK_INT> = Build.VERSION_CODES.HONEYCOMB
             ||  Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2)
     {
         this.setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
     }
  • and finally, my least favorite (sending it to completion, though), drop the ABC and go back to the ABS.

I also posted a ticket for the Android Issue Tracker , but this is a cellular problem, I do not expect to get an answer.

UPDATE:. After the release of the application with a locked orientation for certain cellular devices, I still see that this failure is reported, although less frequently.

UPDATE 2: The problem is fixed! Now just wait for the new lib support to be released: Google bug tracker

+6
source

Source: https://habr.com/ru/post/955388/


All Articles