1

I'v published an application in Play Store. It was regular but in last few month, there are many AndroidRuntimeException in Firebase's Crashlytics. Here are the error stacks:

Caused by android.util.AndroidRuntimeException: Window feature must be requested before adding content
       at androidx.appcompat.app.AppCompatDelegateImpl.throwFeatureRequestIfSubDecorInstalled(AppCompatDelegateImpl.java:2309)
       at androidx.appcompat.app.AppCompatDelegateImpl.requestWindowFeature(AppCompatDelegateImpl.java:1089)
       at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:848)
       at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
       at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
       at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
       at ****.BaseActivity.onCreate(BaseActivity.java:78)

I'v tried different versions of appcompat library, such as 1.1.0-rc011.1.01.2.01.3.0, but it not works. It seams ok in the source code of AppCompatDelageImpl.java.

Can anyone can help me to solve this problem. Thanks a lot.

沈徐乐
  • 23
  • 5

2 Answers2

0

requestFeature() must be called before adding content

Well, just do what the error message tells you.

Don't call setContentView() before requestFeature() .It happens most probably in your Base Activity that you requesting some windows feature after setContentView.

Note: As said in comments, for both ActionBarSherlock and AppCompat library, it's necessary to call requestFeature() before super.onCreate()

Ghulam Qadir
  • 471
  • 3
  • 12
  • It's not must-see bug so it's so wired. And in target class, I didn't call `requestFeature()` func to request some window feature. – 沈徐乐 Dec 01 '20 at 08:34
  • As i have not your code snippet now but may be you call other than BaseActivity file .So checkout firstly. – Ghulam Qadir Dec 01 '20 at 08:41
  • If I called `requestWindowFeature` in `BaseActivity.onCreate`, the bug stack shouldn't contains the `AppCompatActivity.setContentView`'s call. – 沈徐乐 Dec 01 '20 at 08:47
0

Finally, I found the question. We have a track library and it will collect the Activity's title when activity create. And I adjust it to onResume by AOP. Thanks you all a lot.

沈徐乐
  • 23
  • 5