httpCanary
可以在手机上直接看app抓包的软件
使用场景:
1.比较传统的公司没有wifi,不能使用charlse抓包
2.在外面没带电脑,突然报了个问题,可以手机直接看是否接口问题。
使用准备:
1.httpCanary apk
2.app代码配置
httpCanary apk
在网上找一个破解版的,主要是无广告
app代码配置
1.Manifest里的networkSecurityConfig
<!--开发使用-->
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" overridePins="true" /> <!--信任系统证书-->
<certificates src="user" overridePins="true" /> <!--信任用户证书-->
</trust-anchors>
</base-config>
</network-security-config>
2.如果是使用okttp
OkhttpClient里面的proxy 设置成Proxy.NO_PROXY
debug和release配置
开放抓包不能带到线上环境,因此要区分debug和release
Manifest里面通过manifestPlaceHolder来区分
android:networkSecurityConfig="${NETWORK_SECURITY_CONFIG}"
buildTypes{
debug{
manifestPlaceholders = [
NETWORK_SECURITY_CONFIG:"@xml/network_security_config"
]
}
release{
manifestPlaceholders = [
NETWORK_SECURITY_CONFIG:"@xml/network_security_config_release"
]
}
}
okhttp proxy通过代码设置
if (!BuildConfig.DEBUG) {
proxy(Proxy.NO_PROXY)
}