Previous words
Since the Tencent family mobile webview portal has been replaced by x5, the industry has received mixed reviews. Generally speaking, it has brought many surprises to developers, the most important of which is the debugging ability of WeChat x5, In the past, code farmers forced code to complete the local browser. Once the browser ran, a bunch of compatibility problems appeared on WeChat Q, which was horrible. In the past, WeChat Q had no debugging ability and could only use Weinre debugrap and other half baked tools to make do with it
In the twinkling of an eye, 2015 WeChat has opened the webview debugging capability. Debugging with chrome is no longer a dream (skinning breakpoint debugging performance test console, etc.)
Because it is a little complicated to use, the following methods are introduced in module mode:
Debugging principle with the help of Chrome and Android adb functions
preparation in advance
1. Download the latest WeChat for my use is 6.1
2. Download TbsSuiteNew.apk and install it to the mobile phone address( http://res.imtt.qq.com///tbs_inspect/TbsSuiteNew.zip )
- Open WeChat, enter the chat interface (any) input box, enter//deletetbs, and click Send
Enter//gettbs to view the current tbs
4. Open TbsSuiteNew and select local tbs kernel
5. Download tbs debugging package
Application package name WeChat: com. tencent. mm, qq: com. tencent. mobileqq, qq space: com. qzone]
We can choose WeChat
6. Start the silent installation of tbs
7. Log in to WeChat, use WeChat to visit a page, stay for about 1 minute, so that WeChat can silently install the tbs_xxxx_inspector.apk package just imported
8. One minute later, open TbsSuiteNew to check whether the installation is successful
Here, you also need to open WeChat under check, enter a webview page at random, and then long press the page text to see if there are water drops. If there are, it will be successful
ADB installation
Download on official website android-sdk , execute android under the tools folder, and then select android sdk platform tools to install
Then configure the android environment variable vim~/. bash_profile
export ANDROID_TOOLS=/Users/sherlock/dev/android-sdk-macosx/platform-tools
export PATH=$PATH:$ANDROID_TOOLS
Finally, under the execution of source. bash_profile, the environment variable displays the adb on the console to see whether it has been configured!
If you can't find domestic equipment under the ps mac, you can try the following methods:
1. Open the terminal, and the system_profiler SPUSBDataType command can view the information of the connected USB device
2. My name is MX4 PRO. Vendor id of the device: 0x2a45 Product Id: 0x0c02
- Vi~/. android/adb_usb.ini command, add 0x2a45 to the open adb_usb.ini file, and then save to exit
Then restart adb
adb kill-server
adb start-server
Sometimes adb devices cannot display the connected device. You need to unplug the data cable, plug it in several times, exit the terminal, reopen it, and then enter the command to find the connected device. If you cannot connect again, restart the computer and wait for the system to initialize the environment setting.
Adb devices can view the connected devices
Install python
Go to python( https://www.python.org/ )Download the installation package to install and add environment variables so that you can directly access python
Python Start Debugging Service
Download( http://res.imtt.qq.com///tbs_inspect/wx_sq_webview_debug.zip )
The package contains inspector_client20150401.zip
<p>
After the adb installation is completed, we can start the debugging service. Unzip the downloaded wx_sq_webview_debug, find the inspector_client20150401, unzip it, and enter. (Remember to open USB debugging)
Execute the following python command python/ Inspector. py -- abd your own adb path
python ./ inspector.py --adb /Users/sherlock/dev/android-sdk-macosx/platform-tools/adb
Errors may be encountered
device unauthorized. Please check the confirmation dialog on your device.
Please agree to USB debugging on your own device
Last start succeeded
Finally, perfect start debugging
After python starts OK, we can debug happily. What should we do?
Open Chrome browser to access http://localhost:9222/
Open any page on WeChat
You can see the tab of this page on chrome
Click in to see the familiar chrome debugging interface
Breakpoint debugging is OK. The console prints the element selector
For reprint, please indicate the source sherlock221b http://www.jianshu.com/p/ccf124f1f74b
Closing words
So far, the debugging desire of WeChat webview for a hundred years has finally been fulfilled. From then on, we can bid farewell to unstable tools such as weinre debug and usher in a new dawn. Thanks to TX, WeChat will certainly become the battlefield of html5 in the future as x5's capabilities continue.
According to the description of x5, WeChat Messenger q and qq browser have independently inherited x5. We only need to install any one of them to experience the features brought by x5. The x5 sdk also provides the ability to replace local webviews for third-party apps. You can learn more about the x5 browsing service( http://x5.tencent.com/ ). If the third-party app can also integrate x5, we can use this debugging method to debug the webview of our own app