Crash reaction on native component when using PersistableBundle in onCreate android

I am creating a chat application in React native that should be open from Native Android. My activity, ChatActivity was originally developed using onCreate PersistableBundle as follows:

override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
    super.onCreate(savedInstanceState, persistentState)

    mReactRootView = ReactRootView(this)

    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(application)
            .setBundleAssetName("index.android.bundle")
            .setJSMainModulePath("index.android")
            .addPackage(MainReactPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build()

    mReactRootView.startReactApplication(mReactInstanceManager, "AppApplication", null)

    setContentView(mReactRootView)
}

It worked perfectly, but it did not cause every time because of perseverance. I want to call onCreate every time to pass some data. Therefore, I used the onCreate method as follows:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

I do not know how this changed, encoded without a persistent packet failure. The crash report is as follows:

FATAL EXCEPTION: main
Process: com.app.alldaydr, PID: 7255
com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 2
 detail: View tag:7
  children(0): [
 ],
  viewsToAdd(1): [
[0,2],
 ],

    at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:394)
    at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:180)
    at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:815)
    at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:922)
    at com.facebook.react.uimanager.UIViewOperationQueue.access$2100(UIViewOperationQueue.java:47)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:982)
    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
    at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
    at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:964)
    at android.view.Choreographer.doCallbacks(Choreographer.java:778)
    at android.view.Choreographer.doFrame(Choreographer.java:710)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:172)
    at android.app.ActivityThread.main(ActivityThread.java:6637)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

I am new to React development and confused about this. Can someone explain why this behavior occurs?

Am I doing something wrong?

thank

+4
source share

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


All Articles