diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2acab8a..ea62354 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,7 +40,7 @@ android { } dependencies { -// implementation("io.grpc:grpc-core:1.68.0") + implementation(libs.grpc.android) implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(libs.material) diff --git a/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt b/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt index c7127b3..c07ab51 100644 --- a/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt +++ b/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt @@ -4,8 +4,7 @@ import android.util.Log import com.google.protobuf.ByteString import dad.xiaomi.uog.Udp import dad.xiaomi.uog.UdpServiceGrpcKt -//import io.grpc.internal.DnsNameResolverProvider -import io.grpc.okhttp.OkHttpChannelBuilder +import io.grpc.android.AndroidChannelBuilder import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.Channel @@ -40,7 +39,7 @@ class UogClient(val lPort: Int, val endpoint: String, val password: String) { try { val id = random.nextInt(1000); val url = URL(endpoint) - val builder = OkHttpChannelBuilder.forAddress(url.host, url.port) + val builder = AndroidChannelBuilder.forAddress(url.host, url.port) if (!url.protocol.equals("https")) { builder.usePlaintext() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8bff66c..106a544 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] agp = "8.7.0" grpcKotlinStub = "1.4.1" -grpcOkhttp = "1.62.2" +grpcOkhttp = "1.57.2" kotlin = "1.9.24" coreKtx = "1.13.1" junit = "4.13.2" @@ -15,6 +15,7 @@ protobufGradlePlugin = "0.9.4" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +grpc-android = { module = "io.grpc:grpc-android", version.ref = "grpcOkhttp" } protoc = { group = "com.google.protobuf", name = "protoc", version = "3.25.3" } protoc-gen-grpc-java = { group = "io.grpc", name = "protoc-gen-grpc-java", version = "1.62.2" } protoc-gen-grpc-kotlin = { group = "io.grpc", name = "protoc-gen-grpc-kotlin", version = "1.4.1" }