「Fix」
1、修复UnknownHostException问题 java.net.UnknownHostException: Unable to resolve host "eagle-mis.zhidaozhixing.com": No address associated with hostname at
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mogo.cloud.network
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.network.NetConstants.Companion.CONNECT_TIMEOUT
|
||||
import com.mogo.cloud.network.NetConstants.Companion.READ_TIMEOUT
|
||||
import com.mogo.cloud.network.NetConstants.Companion.WRITE_TIMEOUT
|
||||
@@ -10,7 +11,10 @@ import com.mogo.cloud.network.interceptor.HttpHeaderInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpLoggingInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpPassportInterceptor
|
||||
import okhttp3.Dispatcher
|
||||
import okhttp3.Dns
|
||||
import okhttp3.OkHttpClient
|
||||
import java.net.InetAddress
|
||||
import java.net.UnknownHostException
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
@@ -42,9 +46,25 @@ class OkHttpFactory private constructor() {
|
||||
.writeTimeout(WRITE_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.eventListenerFactory(WeakNetworkEventFactory.FACTORY)
|
||||
.dispatcher(dispatcher)
|
||||
// 可选:添加自定义 DNS 解析逻辑
|
||||
.dns(CustomDns()) // 使用系统默认 DNS 或者自定义 Dns 实现
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CustomDns : Dns {
|
||||
override fun lookup(hostname: String): List<InetAddress> {
|
||||
return try {
|
||||
Log.d("CustomDns", "Lookup resolve host: $hostname")
|
||||
// 使用默认的 DNS 解析逻辑
|
||||
Dns.SYSTEM.lookup(hostname)
|
||||
} catch (uhe: UnknownHostException) {
|
||||
// 处理 UnknownHostException
|
||||
// 在这里记录日志、通知用户或其他处理方式
|
||||
Log.e("CustomDns", "Unable to resolve host: $hostname", uhe)
|
||||
// 返回空列表表示无法解析
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,27 +36,27 @@ PASSWORD=xintai2018
|
||||
RELEASE=false
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.4.7.58
|
||||
MOGO_UTILS_VERSION=1.4.7.59
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.4.7.58
|
||||
MOGO_NETWORK_VERSION=1.4.7.59
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.4.7.58
|
||||
MOGO_PASSPORT_VERSION=1.4.7.59
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.4.7.58
|
||||
MOGO_SOCKET_VERSION=1.4.7.59
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.4.7.58
|
||||
MOGO_REALTIME_VERSION=1.4.7.59
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.4.7.58
|
||||
MOGO_TANLU_VERSION=1.4.7.59
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.4.7.58
|
||||
MOGO_LIVE_VERSION=1.4.7.59
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.7.58
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.7.59
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.4.7.58
|
||||
MOGO_LOCATION_VERSION=1.4.7.59
|
||||
# 远程通讯模块
|
||||
MOGO_TELEMATIC_VERSION=1.4.7.58
|
||||
MOGO_TELEMATIC_VERSION=1.4.7.59
|
||||
# v2x
|
||||
MOGO_V2X_VERSION=1.4.7.58
|
||||
MOGO_V2X_VERSION=1.4.7.59
|
||||
# SKIN
|
||||
MOGO_SKIN_VERSION=1.4.7.49.19
|
||||
# SDK
|
||||
@@ -75,7 +75,7 @@ SONATYPE_HOST=S01
|
||||
RELEASE_SIGNING_ENABLED=false
|
||||
# 组织名
|
||||
GROUP=com.mogo.cloud
|
||||
VERSION_NAME=1.4.7.58
|
||||
VERSION_NAME=1.4.7.59
|
||||
# 主页
|
||||
POM_URL=https://gitlab.zhidaoauto.com/SCA/L4HA/AndroidApp/support/countly-sdk-android
|
||||
# 版本控制信息
|
||||
|
||||
Reference in New Issue
Block a user