Tools are the second productive force! ! !
Introduction to Chuck
Chuck is a packet capture tool based on okhttp. Compared with Charles, it is not only easier to use, but also conveniently supports https protocol packet capture.
GitHub address
integrated
Introduce dependencies
debugImplementation 'com.readystatesoftware.chuck:library:1.1.0'
releaseImplementation 'com.readystatesoftware.chuck:library-no-op:1.1.0'
Since such tools are only used during development and debugging, the author provides dependencies in two modes, of which the release mode is an empty implementation.
Add interceptor in okhttp
ChuckInterceptor chuckInterceptor;
OkHttpClient.Builder hcBuilder = new OkHttpClient.Builder();
if(BuildConfig.DEBUG){
chuckInterceptor = new ChuckInterceptor(getApplicationContext());
hcBuilder.addInterceptor(chuckInterceptor);
}
OK, the integration is successful, very simple.
Effect
The effect is gratifying, the request and response messages are very comprehensive, the following is the effect diagram
Recommendations
Integrated with Chuck, everyone can use it, and it is also convenient for testers to view data.