Skip to content

Commit 5b7beb1

Browse files
committed
集成 OkHttp 抓包工具
1 parent 9ce56a2 commit 5b7beb1

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ dependencies {
219219
debugImplementation libs.leakCanary
220220
previewImplementation libs.leakCanary
221221

222+
debugImplementation libs.chucker
223+
previewImplementation libs.chucker
224+
releaseImplementation libs.chuckerNoOp
225+
222226
// 多语种:https://github.com/getActivity/MultiLanguages
223227
// 悬浮窗:https://github.com/getActivity/EasyWindow
224228
// 日志输出:https://github.com/getActivity/Logcat

app/src/main/java/com/hjq/demo/manager/InitManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import androidx.core.content.ContextCompat;
1111
import androidx.lifecycle.Lifecycle;
1212
import androidx.lifecycle.LifecycleOwner;
13+
import com.chuckerteam.chucker.api.ChuckerInterceptor;
1314
import com.google.gson.reflect.TypeToken;
1415
import com.google.gson.stream.JsonToken;
1516
import com.hjq.bar.TitleBar;
@@ -129,6 +130,7 @@ public static void preInitSdk(@NonNull Application application) {
129130

130131
// 网络请求框架初始化
131132
OkHttpClient okHttpClient = new OkHttpClient.Builder()
133+
.addInterceptor(new ChuckerInterceptor(application))
132134
.build();
133135

134136
EasyConfig.with(okHttpClient)

gradle/libs.versions.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ timber = "4.7.1"
2626
circleIndicator = "2.1.6"
2727
mmkv = "2.3.0"
2828
leakCanary = "3.0-alpha-8"
29+
chucker = "4.2.0"
2930
softInputEvent = "1.0.9"
3031
umengCommon = "9.8.8"
3132
umengAsms = "1.8.7.2"
@@ -121,6 +122,10 @@ mmkvStatic = { module = "com.tencent:mmkv-static", version.ref = "mmkv" }
121122
# LeakCanary 内存泄漏监测:https://github.com/square/leakcanary
122123
leakCanary = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakCanary" }
123124

125+
# OkHttp 抓包工具:https://github.com/ChuckerTeam/chucker
126+
chucker = { module = "com.github.chuckerteam.chucker:library", version.ref = "chucker" }
127+
chuckerNoOp = { module = "com.github.chuckerteam.chucker:library-no-op", version.ref = "chucker" }
128+
124129
# 软键盘遮挡解决方案:https://github.com/liangjingkanji/soft-input-event
125130
softInputEvent = { module = "com.github.liangjingkanji:soft-input-event", version.ref = "softInputEvent" }
126131

0 commit comments

Comments
 (0)