Response-native: android.view.WindowManager $ BadTokenException

I have a mistake with which I do not know where to start. Tried to upgrade the reactive version - but that didn't do the trick.

Environment

react-native-cli: 2.0.1
react-native: 0.54.2

Production assembly

The application is created and released in the Google Play Store. So this is a compiled production version. Think of it as a module problem, maybe ... but not quite sure.

this is my import in the main component

import React, { Component } from 'react'
import { View, Modal, Text, TextInput, StyleSheet } from 'react-native'
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'

Fullstack

java.lang.RuntimeException: 

  at com.facebook.react.bridge.ReactContext.handleException (ReactContext.java:313)

  at com.facebook.react.bridge.GuardedRunnable.run (GuardedRunnable.java:23)

  at android.os.Handler.handleCallback (Handler.java:739)

  at android.os.Handler.dispatchMessage (Handler.java:95)

  at android.os.Looper.loop (Looper.java:158)

  at android.app.ActivityThread.main (ActivityThread.java:7225)

  at java.lang.reflect.Method.invoke (Native Method)

  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)

  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: android.view.WindowManager$BadTokenException: 

  at android.view.ViewRootImpl.setView (ViewRootImpl.java:849)

  at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:337)

  at android.view.WindowManagerImpl.addView (WindowManagerImpl.java:91)

  at android.app.Dialog.show (Dialog.java:350)

  at com.facebook.react.views.modal.ReactModalHostView.showOrUpdate (ReactModalHostView.java:256)

  at com.facebook.react.views.modal.ReactModalHostManager.onAfterUpdateTransaction (ReactModalHostManager.java:107)

  at com.facebook.react.views.modal.ReactModalHostManager.onAfterUpdateTransaction (ReactModalHostManager.java:28)

  at com.facebook.react.uimanager.ViewManager.updateProperties (ViewManager.java:35)

  at com.facebook.react.uimanager.NativeViewHierarchyManager.createView (NativeViewHierarchyManager.java:233)

  at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute (UIViewOperationQueue.java:153)

  at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:816)

  at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:929)

  at com.facebook.react.uimanager.UIViewOperationQueue.access$2100 (UIViewOperationQueue.java:47)

  at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded (UIViewOperationQueue.java:887)

  at com.facebook.react.bridge.GuardedRunnable.run (GuardedRunnable.java:21)

UPDATE

I use modal 3 different places.

const Credits = ({ display, toggle }) => (
  <View>
    <TouchableOpacity
      style={[styles.button, styles.info]}
      onPress={() => toggle()}
    >
      <Icon name="question" size={30} color="#000" />
    </TouchableOpacity>

    {display && (
      <Modal
        animationType="slide"
        transparent={true}
        onRequestClose={() => toggle()}
      >
        <View style={styles.card}>
          <ScrollView>
            { ... code ...  }
          </ScrollView>
          <TouchableOpacity
            style={[styles.button, styles.close]}
            onPress={() => toggle()}
          >
            <Icon name="close" size={30} color="#000" />
          </TouchableOpacity>
        </View>
      </Modal>
    )}
  </View>
)

I don’t know if this is because I use logic { display && <Modal .../> }instead of using prop visible={display}???

Any help would be greatly appreciated!

+4
source share
1 answer

React native ; React native activity.isFinishing(), ,

onResume() onPause() , React, , , , React - onResume(). , , - React . Android UI Android.

void onResume(){
    super.onResume();
    activityResumed = true;
    if(showResultsOnResume){
        showResultsOnResume = false;
       //you have saved results from react waiting to show, show it here
     }
}
void onPause(){
       super.onPause();
       activityResumed = false;
}

// use this method to update any UI from React
void onReactResult(/*Results or Errors from React*/){ 
       if(activityResumed){
           // show the result
       }else{
           showResultsOnResume = true;
           // save result
       }
}
0

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


All Articles