3

How to handle this crash? i don't have any file Dns.kt in my project, getting crash on random user.

Dns.kt line 49 okhttp3.Dns$Companion$DnsSystem.lookup enter image description here

Fatal Exception: java.net.UnknownHostException Unable to resolve host "maps.googleapis.com": No address associated with hostname java.net.Inet6AddressImpl.lookupHostByName

Fatal Exception: java.net.UnknownHostException: Unable to resolve host "maps.googleapis.com": No address associated with hostname
       at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
       at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
       at java.net.InetAddress.getAllByName(InetAddress.java:1152)
       at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
       at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
       at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
       at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
       at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
       at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
       at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
       at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
       at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)

Caused by android.system.GaiException android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) okhttp3.Dns$Companion$DnsSystem.lookup

Caused by android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
       at libcore.io.Linux.android_getaddrinfo(Linux.java)
       at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:74)
       at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:200)
       at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:74)
       at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
       at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
       at java.net.InetAddress.getAllByName(InetAddress.java:1152)
       at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
       at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
       at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
       at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
       at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
       at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
       at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
       at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
       at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
       at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)

enter image description here

Hari Shankar S
  • 3,330
  • 4
  • 19
  • 36
  • Did you got any solution for this – Ameer Jul 19 '21 at 09:23
  • no i getting error in live user app, i am unable to replicate this issue & no solution. – Hari Shankar S Jul 20 '21 at 04:11
  • This might happened when you are in the app and device has no internet connection. That is how we are able to reproduce this issue, just turn off WiFi and Mobile data and app crashes after few seconds. – adi9090 Nov 11 '21 at 12:48
  • Hello, we are facing same issue. Double checking if you were able to solve it. – Akshay May 27 '22 at 20:02

2 Answers2

0

Try to add own dns to okhttp to catch exception. I didn't check it.

OkHttpClient.Builder()
    .dns(object : Dns {
        override fun lookup(hostname: String): List<InetAddress> {
            return try {
                Dns.SYSTEM.lookup(hostname)
            } catch (t: Throwable) {
                emptyList()
            }
        }
    })

You can also override ip addresses for your hostnames here if you want.

Sergei K
  • 887
  • 11
  • 12
-4

You may need to ask for Internet permission at Android Manifest as stated on this answer: https://stackoverflow.com/a/6355961/11840668

Jorge C.M
  • 377
  • 3
  • 10
  • thank u for reply, but i already define internet permission in manifeast, i got this crash from playstore live user, can't replicate in debug – Hari Shankar S Jun 21 '21 at 07:47