How debug nativescript code?

后端 未结 1 1767
灰色年华
灰色年华 2021-01-29 01:01

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

相关标签:
1条回答
  • 2021-01-29 01:35

    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:

    1. When you don't have a running application - you will have to use tns debug android --debug-brk and it will run the application and open the debugger
    2. If you already have run the application with tns 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
    3. If you would like to be able to type other commands in the current console, you can use tns run android --justlaunchand 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.

    0 讨论(0)
提交回复
热议问题