Nativescript: Split View Crash

Created on 11 Feb 2019  路  15Comments  路  Source: NativeScript/NativeScript

@vbresults commented on Sat Feb 09 2019

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.1.1
  • Android Runtime: 5.1.0

    • Android API Level: 25

Describe the bug
If you are outside the NS app (i.e. Settings app) and NS launches from tns run android, the screen is split into two with a slider. If you choose to move the slider up to dismiss the non-NS app, the NS app will crash with the attached error.

To Reproduce
Move the slider up to dismiss the non-NS app, the NS app will crash with the attached error.

Additional context

02-09 12:22:52.003  6010  6010 W System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
02-09 12:22:52.003  6010  6010 W System.err: Calling js method onCreate failed
02-09 12:22:52.003  6010  6010 W System.err: 
02-09 12:22:52.003  6010  6010 W System.err: Error: java.lang.NullPointerException: Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference
02-09 12:22:52.003  6010  6010 W System.err:     org.nativescript.widgets.GridLayout.removeFromMap(GridLayout.java:229)
02-09 12:22:52.003  6010  6010 W System.err:     org.nativescript.widgets.GridLayout.removeView(GridLayout.java:135)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:987)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:967)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:959)
02-09 12:22:52.003  6010  6010 W System.err:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.Activity.performCreate(Activity.java:6679)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.ActivityThread.-wrap19(ActivityThread.java)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
02-09 12:22:52.003  6010  6010 W System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
02-09 12:22:52.003  6010  6010 W System.err:     android.os.Looper.loop(Looper.java:154)
02-09 12:22:52.003  6010  6010 W System.err:     android.app.ActivityThread.main(ActivityThread.java:6119)
02-09 12:22:52.003  6010  6010 W System.err:     java.lang.reflect.Method.invoke(Native Method)
02-09 12:22:52.003  6010  6010 W System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
02-09 12:22:52.003  6010  6010 W System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
02-09 12:22:52.003  6010  6010 W System.err: File: "file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view.js, line: 733, column: 23
02-09 12:22:52.003  6010  6010 W System.err: 
02-09 12:22:52.003  6010  6010 W System.err: StackTrace: 
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'CustomLayoutView._removeViewFromNativeVisualTree', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 733, column: 24
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'WebView._tearDownUI', file:'file:///data/data/com.example.app/files/app/tns_modules/nativescript-web-view/web-view.js', line: 147, column: 25
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 486, column: 18
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ContentView.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'PageBase.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'FrameBase.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 368, column: 13
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 917, column: 22
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 763, column: 14
02-09 12:22:52.003  6010  6010 W System.err:    Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25
02-09 12:22:52.003  6010  6010 W System.err: 
02-09 12:22:52.003  6010  6010 W System.err:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
02-09 12:22:52.003  6010  6010 W System.err:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
02-09 12:22:52.003  6010  6010 W System.err:    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519)
02-09 12:22:52.003  6010  6010 W System.err:    at android.app.ActivityThread.-wrap19(ActivityThread.java)
02-09 12:22:52.003  6010  6010 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
02-09 12:22:52.003  6010  6010 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
02-09 12:22:52.003  6010  6010 W System.err:    at android.os.Looper.loop(Looper.java:154)
02-09 12:22:52.003  6010  6010 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:6119)
02-09 12:22:52.003  6010  6010 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
02-09 12:22:52.003  6010  6010 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
02-09 12:22:52.003  6010  6010 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
02-09 12:22:52.003  6010  6010 W System.err: Caused by: com.tns.NativeScriptException: 
02-09 12:22:52.003  6010  6010 W System.err: Calling js method onCreate failed
02-09 12:22:52.003  6010  6010 W System.err: 
02-09 12:22:52.003  6010  6010 W System.err: Error: java.lang.NullPointerException: Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference
02-09 12:22:52.003  6010  6010 W System.err:     org.nativescript.widgets.GridLayout.removeFromMap(GridLayout.java:229)
02-09 12:22:52.004  6010  6010 W System.err:     org.nativescript.widgets.GridLayout.removeView(GridLayout.java:135)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:987)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:967)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:959)
02-09 12:22:52.004  6010  6010 W System.err:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.Activity.performCreate(Activity.java:6679)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.ActivityThread.-wrap19(ActivityThread.java)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
02-09 12:22:52.004  6010  6010 W System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
02-09 12:22:52.004  6010  6010 W System.err:     android.os.Looper.loop(Looper.java:154)
02-09 12:22:52.004  6010  6010 W System.err:     android.app.ActivityThread.main(ActivityThread.java:6119)
02-09 12:22:52.004  6010  6010 W System.err:     java.lang.reflect.Method.invoke(Native Method)
02-09 12:22:52.004  6010  6010 W System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
02-09 12:22:52.004  6010  6010 W System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
02-09 12:22:52.004  6010  6010 W System.err: File: "file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view.js, line: 733, column: 23
02-09 12:22:52.004  6010  6010 W System.err: 
02-09 12:22:52.004  6010  6010 W System.err: StackTrace: 
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'CustomLayoutView._removeViewFromNativeVisualTree', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 733, column: 24
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'WebView._tearDownUI', file:'file:///data/data/com.example.app/files/app/tns_modules/nativescript-web-view/web-view.js', line: 147, column: 25
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 486, column: 18
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ContentView.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'PageBase.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 19
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'FrameBase.eachChildView', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 368, column: 13
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 884, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 532, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 917, column: 22
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 763, column: 14
02-09 12:22:52.004  6010  6010 W System.err:    Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.example.app/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25
02-09 12:22:52.004  6010  6010 W System.err: 
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.Runtime.callJSMethodNative(Native Method)
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:987)
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:967)
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:959)
02-09 12:22:52.004  6010  6010 W System.err:    at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18)
02-09 12:22:52.004  6010  6010 W System.err:    at android.app.Activity.performCreate(Activity.java:6679)
02-09 12:22:52.004  6010  6010 W System.err:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
02-09 12:22:52.004  6010  6010 W System.err:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
02-09 12:22:52.004  6010  6010 W System.err:    ... 10 more
02-09 12:22:52.004  6010  6010 W System.err: Caused by: java.lang.NullPointerException: Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference
02-09 12:22:52.004  6010  6010 W System.err:    at org.nativescript.widgets.GridLayout.removeFromMap(GridLayout.java:229)
02-09 12:22:52.004  6010  6010 W System.err:    at org.nativescript.widgets.GridLayout.removeView(GridLayout.java:135)

@tsonevn commented on Mon Feb 11 2019

Hi @vbresults,
I tested your scenario in a sample project on Android device, however, was unable to recreate the issue. For your convenience, I am attaching the project. Please review it and make the needed changes, that will help us in recreating the problem.

Meanwhile, make sure that you have added keyboard|smallestScreenSize|screenLayout|locale|uiMode options in the configChanges in your AndroidManifest.xml file.

For example:

android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"

Archive.zip

needs more info

Most helpful comment

Hi @xlmnxp,
I found out that the crash in the project is related to the custom login implemented inside of the TabView's loaded event(disableFocusSearchBar callback method in your code) in posts.component.ts. In disableFocusSearchBar, you are using the removeViewAt native method to remove one of the TabView's child views(this.tabview.nativeElement.android.removeViewAt(1);). This method will remove the needed child view successfully when the page is initially loaded. However, when you make forward and them backwards navigation, you will try to remove the non-existing native child view again. To solve your case, you need first to check if the child view exists and then try to remove it. For example:

disableFocusSearchBar() {
    var searchBar: SearchBar = <SearchBar>this.searchBar.nativeElement;
    if (isAndroid) {
      searchBar.parent.android.setFocusableInTouchMode(true);
      searchBar.parent.android.setFocusable(true);
      searchBar.nativeView.setFocusable(false);
      searchBar.nativeView.clearFocus();
      if(this.tabview.nativeElement.android.getChildAt(1)){
        this.tabview.nativeElement.android.removeViewAt(1);
      }
    } else {
      this.tabview.nativeElement.ios.tabBar.hidden = true;
    }

    ad.dismissSoftInput();
  }

All 15 comments

Closing due to inactivity

reopen issue because it important to fix
I think error come from GridLayout.java:229 and GridLayout.java:142 when page destroyed

@xlmnxp
Check out the above-given solution ->

_make sure that you have added keyboard|smallestScreenSize|screenLayout|locale|uiMode options in the configChanges in your AndroidManifest.xml file._

_For example:_

android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"

```

@tsonevn same thing
problem come in iOS too (take long time to back)

I think problem not in split view
It's come when gridlayout removed from page ( when page destroy )

JS: ERROR Error: java.lang.NullPointerException: Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference JS: org.nativescript.widgets.GridLayout.removeFromMap(GridLayout.java:229) JS: org.nativescript.widgets.GridLayout.removeViewAt(GridLayout.java:142) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:996) JS: com.tns.Runtime.callJSMethod(Runtime.java:983) JS: com.tns.Runtime.callJSMethod(Runtime.java:967) JS: com.tns.Runtime.callJSMethod(Runtime.java:959) JS: com.tns.NativeScriptActivity.onStart(NativeScriptActivity.java:49) JS: android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334) JS: android.app.Activity.performStart(Activity.java:7029) JS: android.app.Activity.performRestart(Activity.java:7104) JS: android.app.Activity.performResume(Activity.java:7109) JS: android.app.ActivityThread.performResumeActivity(Activ...

Hi @xlmnxp,
Can you send us a sample project and the exact steps, that you are using for recreating it?

@tsonevn I have private project, I invited you

Hi @xlmnxp,
I just checked, but I haven't received any invitations yet in GitHub by you.

Hi @xlmnxp,
I reviewed your project and noticed that you are using an old tns-core-modules, tns-ios, tns-android and nativescript-angular versions. Try to upgrade your project to the latest available versions(tns-core-modules v.5.3.2, tns-ios v.5.3.1, tns-android v. 5.3.1, nativescript-angular v.7.2.3, NativeScript CLI v.5.3.4) and check if you will be able to recreate the issue. For further help, you can review the upgrade instructions here.

@tsonevn same after upgrade
JS: ERROR Error: java.lang.NullPointerException: Attempt to write to field 'android.view.View org.nativescript.widgets.MeasureSpecs.child' on a null object reference JS: org.nativescript.widgets.GridLayout.removeFromMap(GridLayout.java:229) JS: org.nativescript.widgets.GridLayout.removeViewAt(GridLayout.java:142) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:1083) JS: com.tns.Runtime.callJSMethod(Runtime.java:1070) JS: com.tns.Runtime.callJSMethod(Runtime.java:1050) JS: com.tns.Runtime.callJSMethod(Runtime.java:1042) JS: com.tns.FragmentClass.onCreateView(FragmentClass.java:54) JS: android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) JS: android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) JS: android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) JS: android.support.v4.app.FragmentManagerImpl.moveToStat... JS: ERROR CONTEXT { JS: "view": { JS: "def": { JS: "nodeFlags": 960577681, JS: "rootNodeFlags": 939524113, JS: "nodeMatchedQueries": 4094, JS: "flags": 0, JS: "nodes": [ JS: { JS: "nodeIndex": 0, JS: "parent": null, JS: "renderParent": null, JS: "bindingIndex": 0, JS: "outputIndex": 0, JS: "checkIndex": -1, JS: "flags": 16, JS: "childFlags": 0, JS: "directChildFlags": 0, JS: "childMatchedQueries": 0, JS: "matchedQueries": {}, JS: "matchedQueryIds": 0, JS: "references": {}, JS: "ngContentIndex": -1, JS: "childCount": 0, JS: "bindings": [], JS: "bindingFlags": 0, JS: "outputs": [], JS: "element": null, JS: "provider": { JS: "deps": [] JS: }, JS: "text": null, JS: "query": null, JS: "ngContent": null JS: }, JS: { JS: "nodeIndex": 1, JS: "parent": null, JS: "renderParent": null, JS: "bindingIndex": 0, JS: "outputIndex"...

you will find it when come back from page post-view

demo account:-
username: demo
password: demodemo

Hi @xlmnxp,
Excuse me for the delay in reply.
I checked yesterday the project from the repository that you have attached, however, I am still not able to build the project for Android. For iOS I there is no problem with the Split view functionality. Check out the attached GIF.
Screencast 2019-05-28 at 1 52 29 PM

On that matter, I noticed that some of the plugins are not the latest version(e.g. nativescript-photoviewer, nativescript-web-image-cache, etc.) and this might be related to the crash. Try to upgrade also all plugins to their most recent version and check if the issue will be resolved.

@tsonevn

Excuse me for the delay in reply.

np :)

I checked yesterday the project from the repository that you have attached, however, I am still not able to build the project for Android. For iOS I there is no problem with the Split view functionality. Check out the attached GIF.

see youtube video to know issue

Hi @xlmnxp,
I found out that the crash in the project is related to the custom login implemented inside of the TabView's loaded event(disableFocusSearchBar callback method in your code) in posts.component.ts. In disableFocusSearchBar, you are using the removeViewAt native method to remove one of the TabView's child views(this.tabview.nativeElement.android.removeViewAt(1);). This method will remove the needed child view successfully when the page is initially loaded. However, when you make forward and them backwards navigation, you will try to remove the non-existing native child view again. To solve your case, you need first to check if the child view exists and then try to remove it. For example:

disableFocusSearchBar() {
    var searchBar: SearchBar = <SearchBar>this.searchBar.nativeElement;
    if (isAndroid) {
      searchBar.parent.android.setFocusableInTouchMode(true);
      searchBar.parent.android.setFocusable(true);
      searchBar.nativeView.setFocusable(false);
      searchBar.nativeView.clearFocus();
      if(this.tabview.nativeElement.android.getChildAt(1)){
        this.tabview.nativeElement.android.removeViewAt(1);
      }
    } else {
      this.tabview.nativeElement.ios.tabBar.hidden = true;
    }

    ad.dismissSoftInput();
  }

@tsonevn Fix the problem
Thank you for the solution :smile:


I'm very sorry to bother you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NordlingDev picture NordlingDev  路  3Comments

kn9ts picture kn9ts  路  3Comments

fmmsilva picture fmmsilva  路  3Comments

hshristov picture hshristov  路  3Comments

OscarLopezArnaiz picture OscarLopezArnaiz  路  3Comments