scenarios Handling with Retrofit and Kotlin Coroutines in Android - 'No address associated with hostname'
I'm attempting to set up Hey everyone, I'm running into an issue that's driving me crazy... I'm working with an scenario while making network requests using Retrofit in my Android application... I'm using Kotlin Coroutines for asynchronous calls, and I keep getting the behavior 'java.net.UnknownHostException: No address associated with hostname'. This happens on devices connected to mobile data but not on Wi-Fi, which is confusing. I've checked my base URL, and it seems correct. Here's the Retrofit setup I have: ```kotlin val retrofit = Retrofit.Builder() .baseUrl("https://api.example.com/") .addConverterFactory(GsonConverterFactory.create()) .build() val apiService = retrofit.create(ApiService::class.java) ``` When I try to fetch data, I call this function: ```kotlin suspend fun fetchData() { try { val response = apiService.getData() // Handle the response } catch (e: Exception) { Log.e("NetworkError", e.localizedMessage ?: "An behavior occurred") } } ``` I've also added necessary internet permissions in the manifest file: ```xml <uses-permission android:name="android.permission.INTERNET" /> ``` To troubleshoot, I verified my API endpoint with Postman, and it works fine. I've tried adding timeouts in Retrofit configuration and also checked for any VPNs or proxies that might be causing issues, but the question continues. Is there something specific I might be missing related to network configuration or handling this behavior when using Retrofit with coroutines? Any insights would be greatly appreciated! For context: I'm using Kotlin on macOS. Has anyone else encountered this? This is part of a larger application I'm building. Is there a better approach? What am I doing wrong?