cordova application debugging using mobile phone

For the debugging of the cordova application, the most convenient way to debug is to debug it in the browser as an h5 application, and then package the cordova application and package apk after debugging. However, there are a few cases where the effect of h5 application will be different from the final operation on an Android phone. Therefore, a solution that can be debugged on a mobile phone is also required.

 

First, open the following files of vue1, modify it, and add debugger and console.log commonly used for debugging

 

Modify the packaging configuration of vue1, so that the packaged js files are kept as they are to facilitate debugging

Modify the production environment (prod) configuration file of webpack

Comment out the following

PS: The commented out UglifyJsPlugin is used for js packaging, compression and obfuscation

 

PS: The above modification should be changed back after debugging

 

Then use build to package (same as general packaging)

 

PS: Note that the random number of the js file name of the packaged output will not change, but the file content has actually changed. The reason may be that the content of the developed js file has not changed.

 

The following operations are the same as usual, and finally plug in the phone to start debugging

 

After the mobile phone debugging starts, open the chrome browser (only chrome, other ie can't do anything), click on f12 debugging, and then enter the remote device debugging tool here

Find the debugged phone on the far left, the program running on the device in the middle, and finally click inspect on the right to start debugging

After success, you can see the following interface, you can start debugging

PS: There may be a white screen here, this blog has a solution

You can see that you can use the debugger to break the point, and you can also see the variable value

console.log output also works

 

PS: This method is still quite troublesome, especially after modifying the code, vue1 needs to build, copy the files to www, and then run cordova, which is still very time-consuming, and needs to find a better way

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325164400&siteId=291194637