React-native: App crashes when coming back from another activity with landscape orientation On Android 8.1

Created on 12 Nov 2018  ·  27Comments  ·  Source: facebook/react-native

Environment

[skip envinfo]

Description

I have a Reat Native v0.44 Main Activity A which is configured as portrait orientation while destination Activity B is landscape, when A startActivityForResult to B and B finished ok with result to pass to A, the App crashed.

If using following code to set orientation in B, the problem could be solved temporarily:

              boolean isOverAndroid8 = Build.VERSION.SDK_INT > Build.VERSION_CODES.N;
        if (isOverAndroid8) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }

below is styles.xml:
````

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>


````

So, i think it has something related between Reat Native and Android 8.1.

Bug Android

Most helpful comment

Hi friends, after a long time I managed to fix this error.
You need to add android: launchMode = "singleTask" in AndroidManifest.xml

what would it be like this

android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleTask" // ++++++++++++++
>

I had a problem due to react-native-splash-screen library

All 27 comments

I have the same problem ,my react native version is 0.56.0 , but my all activity is setted android:screenOrientation="portrait" , so I guess it has something related between React Native and Android 8.1,maybe the orientation has no effect,the crash information is:
Fatal Exception: java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: MainActivity Paused activity: MainActivity
at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:72)
at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:500)
at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:99)
at com.facebook.react.ReactActivity.onPause(ReactActivity.java:58)
at android.app.Activity.performPause(Activity.java:7422)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1409)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4176)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4153)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4122)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4096)
at android.app.ActivityThread.-wrap15(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1779)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7015)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:521)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:837)

I got 3 crashes too. The information of my environment is:

  • react: 16.2.0
  • react-native: 0.55.3
  • All crashes using portrait screen orientation.
  • 2 crashes Android OS 8.1.0 (Samsung Galaxy Note 9 and LG Stylo 4), 1 crash Android OS 9 (Google Pixel).

The crash information is:
Fatal Exception: java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: MainActivity Paused activity: MainActivity at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:72) at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:500) at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:96) at com.facebook.react.ReactActivity.onPause(ReactActivity.java:58) at android.app.Activity.performPause(Activity.java:7337) at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1465) at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4022) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3987) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3939) at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6680) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

We haven't been able to reproduce it. It has appeared to some users.

Same problem.

react: 16.0.0
react-native: 0.51.0
portrait screen orientation.
Android 8.1

Samsung Galaxy Tab A (2016) (gtaxlwifi), Android 8.1
java.lang.AssertionError:
at com.facebook.infer.annotation.Assertions.assertCondition (Assertions.java:72)
at com.facebook.react.ReactInstanceManager.onHostPause (ReactInstanceManager.java:568)
at com.facebook.react.ReactActivityDelegate.onPause (ReactActivityDelegate.java:119)
at com.facebook.react.ReactActivity.onPause (ReactActivity.java:60)
at android.app.Activity.performPause (Activity.java:7487)
at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1416)
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4130)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4107)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4081)
at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:4055)
at android.app.ActivityThread.-wrap16 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1736)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:7000)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)

same problem

"react": "16.4.1",

"react-native": "^0.55.4",

devices : MI 8 SE | MI 8 | Mi Note 3

android : 8.1.0

1 java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: MainActivity Paused activity: MainActivity
2 at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:72)
3 at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:524)
4 at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:96)
5 at com.facebook.react.ReactActivity.onPause(ReactActivity.java:60)
6 at com.aoaola.MainActivity.onPause(MainActivity.java:32)
7 at android.app.Activity.performPause(Activity.java:7439)
8 at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1409)
9 at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4173)
10 at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4150)
11 at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4119)
12 at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4093)
13 at android.app.ActivityThread.-wrap15(Unknown Source:0)
14 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784)
15 at android.os.Handler.dispatchMessage(Handler.java:106)
16 at android.os.Looper.loop(Looper.java:197)
17 at android.app.ActivityThread.main(ActivityThread.java:7022)
18 at java.lang.reflect.Method.invoke(Native Method)
19 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:515)
20 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:837)

Hey everyone, this issue has quite a few different stack traces, versions of React Native and devices. Is is possible someone could create a repro which we can use to debug the problem locally?

@orta how would I do this?

RN : 0.58.4
Screen Shot 2019-03-20 at 10 25 00 AM

Hi everyone, I have the same issue:

Fatal Exception: java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: MainActivity Paused activity: MainActivity
    at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:72)
    at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:497)
    at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:99)
    at com.facebook.react.ReactActivity.onPause(ReactActivity.java:58)
    at android.app.Activity.performPause(Activity.java:7606)
    at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1465)
    at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4245)
    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4210)
    at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4162)
    at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7045)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

Environment:

Galaxy Note 8: Android version 9
react-native: 0.57.0

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Hi @sduqlsc , did you find a solution?

@truongluong1314520 no, till now, still using above code to fix the orientation.

Hello, we also get this error on react native 0.59.10. Is there a solution to this problem?

phone_model: SM-J710F
android_version: 7.0

java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: MainActivity Paused activity: MainActivity
at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:72)
at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:511)
at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:94)
at com.facebook.react.ReactActivity.onPause(ReactActivity.java:58)
at android.app.Activity.performPause(Activity.java:7161)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1330)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4168)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4145)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4119)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4093)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1654)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Also getting this, with the same trace backs that have been posted here already.

the issue is still there with react-native 0.59.10

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

still happening on 0.60.5

I am facing this issue in react-native version :0.61.5

The same here, just deployed updated app with 0.61.5 react native and facing the same issue across multiple users:
java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: MainActivity Paused activity: MainActivity
at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:72)
at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:512)
at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:99)
at com.facebook.react.ReactActivity.onPause(ReactActivity.java:58)
at android.app.Activity.performPause(Activity.java:8168)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1508)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4725)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4686)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4638)
at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2146)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

It's also in react-native version: 0.61.5

Привет друзья, спустя долгое время мне удалось исправить данную ошибку.
Необходимо в AndroidManifest.xml добавить android:launchMode="singleTask"

что бы было вот так

android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleTask" // ++++++++++++++
>

у меня была проблема из за библиотеки react-native-splash-screen

Hi friends, after a long time I managed to fix this error.
You need to add android: launchMode = "singleTask" in AndroidManifest.xml

what would it be like this

android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleTask" // ++++++++++++++
>

I had a problem due to react-native-splash-screen library

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

It is still happening and was not properly fixed. Could please someone look into it?

I've the same issue in react-native: 0.63.3
I tested with android:launchMode="singleTask" and android:launchMode="singleTop", both with the same issue

Anyone could fix it? Or know how to reproduce?
I'm also using expo, expo-splash-screen, expo-updates... I don't know if the issue can be related with any of these libraries

I have the same problem
"react-native": "0.62.2"
android:launchMode="singleTop"
Probably related to the use react-native-splash-screen

I have the same problem

"react-native": "0.62.2"
android:launchMode="singleTask"

Probably related to the use react-native-splash-screen
Android Sdk 28
Android System Version 8.0.0

Was this page helpful?
0 / 5 - 0 ratings