I am just starting out with nativescript so please mind if this is just a simple question.
I run my code on my phone with tns run android
but when it starts
You can use the debugger tool, available for the JavaScript virtual machine. You can find more information about it in the NativeScript documentation - debugging. Basically to use the debugger you will need Chrome browser. There are several options to run it:
tns debug android --debug-brk
and it will run the application and open the debuggertns run android
or tns livesync android --watch
(bellow there is more information about this command), you will not be able to write any other command in the current console window. In that case you can open one more console window and you type tns debug android --start
tns run android --justlaunch
and after that you will be able to type in the same console window tns debug android --start
.If you would like to have all of your console.log()
statements printed on one place, you can use Android Device Monitor. To run it write monitor
in you console and it will appear. There you can create a new filter for your console.log()-s. In the dialog box, which will appear after pressing the green plus icon, in the field by Log Tag you have to write JS. Then after running your application you can press on the name, you gave to that filter, and you will see all of the console.log() statements from you app.
What would be more convenient in order to use the monitor, is to use the command tns livesync android --watch
. By using it you will have your application automatically run after you save the changes you have made. Keep also in mind that sometimes the monitor simply disconnects and you will have to run it again.