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):
Describe the bug
When I updated Nativescript I got a runtime error in the main-page telling me that I can't navigate to the next page (it's called movimientospages/movimientos-home). The console tells me that the challenge is originated in the topmost.navigate() command.
An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException:
Calling js method onTouch failedTypeError: Cannot read property 'onNavigatingTo' of undefined
File: "file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js, line: 228, column: 40StackTrace:
Frame: function:'FrameBase._onNavigatingTo', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 266, column: 37
Frame: function:'FrameBase.performNavigation', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 238, column: 14
Frame: function:'FrameBase._processNextNavigationEntry', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 231, column: 22
Frame: function:'Frame._processNextNavigationEntry', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 143, column: 58
Frame: function:'FrameBase.navigate', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/frame/frame-common.js', line: 132, column: 14
Frame: function:'onTapMovimientos', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/main-page.js', line: 108, column: 36
Frame: function:'_executeCallback', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js', line: 282, column: 27
Frame: function:'TapAndDoubleTapGestureListenerImpl.onSingleTapUp', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js', line: 25, column: 17
Frame: function:'GesturesObserver.androidOnTouchEvent', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/gestures/gestures.js', line: 228, column: 41
Frame: function:'', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 248, column: 25
Frame: function:'View.handleGestureTouch', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 247, column: 18
Frame: function:'TouchListenerImpl.onTouch', file:'file:///data/data/org.nativescript.PrimeraPrueba/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 37, column: 19at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
at com.tns.Runtime.callJSMethod(Runtime.java:983)
at com.tns.Runtime.callJSMethod(Runtime.java:967)
at com.tns.Runtime.callJSMethod(Runtime.java:959)
at com.tns.gen.java.lang.Object_view_31_32_TouchListenerImpl.onTouch(Object_view_31_32_TouchListenerImpl.java:18)
at android.view.View.dispatchTouchEvent(View.java:11721)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)
at android.app.Activity.dispatchTouchEvent(Activity.java:3292)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)
at android.view.View.dispatchPointerEvent(View.java:11964)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6541)
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)
My appRoot.xml page:
<Frame defaultPage="main-page" id="topmost">
</Frame>
my main-page.js
var Sqlite = require("nativescript-sqlite");
//var createViewModel = require("./main-view-model").createViewModel;
var createViewModel = require("~/main-view-model").createViewModel;
//var createViewModel = require("main-view-model").createViewModel;
//const frames = require("ui/frame");
var frames = require("tns-core-modules/ui/frame");
function onNavigatingTo (args) {
var page = args.object;
(new Sqlite("Pastos.db")).then(async function(db){
await db.execSQL("CREATE TABLE IF NOT EXISTS Usuarios (IdUsuario TEXT PRIMARY KEY , NombreUsuario TEXT,TipoUsuario TEXT, Contrasenia TEXT, Nombre TEXT, Apellido TEXT, DateCreated TEXT, DateUpdated TEXT, IsSynced INTEGER)").then(id => {
console.log("Tabla Usuarios Creada", id);
}, error => {
console.log("CREATE TABLE Usuarios ERROR", error);
}
);
console.log("Ya pas贸 por Usuarios");
page.bindingContext = createViewModel(db);
console.log("Ya cre贸 el viewModel");
}, error => {
console.log("OPEN DB ERROR", error);
}
);
}
function onTapMovimientos(args){
console.log("Entr贸 a onTapMovimientos");
var myTopMostFrame = frames.getFrameById("topmost");
var navigationEntry = {
moduleName: "movimientospages/movimientos-home",
animated: true,
transition: {
name: "slideLeft"
}
};
console.log("Justo antes de rutear navigationEntry");
console.dir(navigationEntry);
console.log("Topmost: " + myTopMostFrame);
//myTopMostFrame.navigate("error");
frames.getFrameById("topmost").navigate(navigationEntry);
}
exports.onNavigatingTo = onNavigatingTo;
exports.onTapMovimientos = onTapMovimientos;
my movimientos-home.js page.
//var createViewModel = require("./main-view-model").createViewModel;
var frames = require("tns-core-modules/ui/frame");
function onTapIngresos(args){
var navigationEntry = {
moduleName: "movimientospages/ingresodeganado/ingresodeganado",
transition: {
name: "slideLeft"
}
};
frames.topmost().navigate(navigationEntry);
}
exports.onTapIngresos = onTapIngresos;
To Reproduce
To reproduce the behavior it's needed to execute the app and, in the main page, to press the "Movimientos" button.
As a note, when I change the navigationEntry's module to a simpler page (like error.xml) the app navigates successfully to the error.xml page. The issue occurs when given the path to navigate to the "movimientos-home" page.
I uploaded the code to a repository where it can be seen. The link to it is:
https://github.com/usjose/secondtry/tree/1cb42353daab5487aadc48e32a75805ccf1ed34c/secondtry/app
Expected behavior
The expected behavior is to navigate to the "movimientospages/movimientos-home" page.
Sample project
https://github.com/usjose/secondtry/tree/1cb42353daab5487aadc48e32a75805ccf1ed34c/secondtry/app
Additional context
The behavior happens in Android and iOS.
I highly appreciate your help.
Thank you.
Hi @usjose,
Thank you for the attached project.
The issue was related to the fact that you are setting up the required min width for the movimientos page to be 600 dp. This means that if you are using a device with a smaller width. The page's XML will not be loaded on a device with smaller width, and in this case, the error will be fired, because you are trying to navigate to an undefined page.
To solve the issue, you can specify different required width and height. For example:
movimientos-home.minWH600.xml->movimientos-home.minWH300.xml.
Or you can remove minWH600 from the name(e.g.movimientos-home.xml).
Hi, @tsonevn.
Thank you so much for your response, and for taking the time to write back.
The explanation you gave makes sense. I already change the name of the file, taking out the minWH600, but it didn't change the issue. The issue is still there.
The weird thing is that, before updating, the app was working well. The app had always the names with the minWH600 and were debugged using a 10.1 Android tablet and an iPhone 6 (All simulated in the Mac).
As a curious thing, the error asks for a "onNavigatingTo" property that the page movimientos never has.
You know, Nikolay?. Although the issue is still not resolved, I appreciate so much your help. I have been trying to solve this issue many days ago with no avail. I'm happy to know that I have a community that helps me.
We'll check what's going on. Thank you.
I'm facing the same issue on iOS
Hi @usjose,
I have checked again the project and found that you need to define movimientos-home.xml and movimientos-home.minWH600.xml in your project. This is needed because if you have a device which have smaller width or height from the requested one(in your case you are requesting the min-width and min-height to be 600), the page will not be loaded. When you've made those changes, the movimientos-home.minWH600.xml will be loaded when the device coresponse on the condition and movimientos-home.xml will be used, when the condition doesn't. I am attaching the project with the needed changes.
Archive.zip
Hi, Nikolay. How are you?.
I applied the changes you gave to me and I'm so happy to see the application works. I want to thank you for your help and to teach me a new thing about NativeScript.
I wish you a Great Day, Nikolay. It's a pleasure to meet you.
Thank you!.
Jos茅
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi, Nikolay. How are you?.
I applied the changes you gave to me and I'm so happy to see the application works. I want to thank you for your help and to teach me a new thing about NativeScript.
I wish you a Great Day, Nikolay. It's a pleasure to meet you.
Thank you!.
Jos茅