How to allow all types of network connections HTTP and HTTPS in Android 9 (Pie) on Kotlin?
Hi! I'm developing an Android app in Kotlin and encountered a problem when testing on a device with Android 9 (Pie). My app sends HTTP requests to a server that uses both HTTPS and HTTP (for test environment). On Android 8 and below everything worked fine, but on Android 9 (API 28) I get the error "Cleartext HTTP traffic to my-server.com not permitted".\n\nHere's how I make the request using Retrofit:\n\n```kotlin\ninterface ApiService {\n @GET("api/data")\n suspend fun getData(): Response\n}\n\nval retrofit = Retrofit.Builder()\n .baseUrl("http://my-test-server.com/")\n .addConverterFactory(GsonConverterFactory.create())\n .build()\n```\n\nI understand that Google tightened security requirements in Android 9, but I need to temporarily
No answers yet.
Log in to leave an answer
Blogs