My project was targeting SDK27 and was working fine and heavily tested. Since google play want to target SDK28, I changed target to SDK28.
After this I started having issue connecting to server in (only) android 9. This turned out to be clearTextTraffic disabled issue as the server doesn't have https (mine is a small app). After adding android:usesCleartextTraffic="true"
in AndroidManifest.xml, this issue was solved and app is again connecting to server as before.
I also have an image upload page using MultipartUploadRequest and this was also failing after SDK28 and this is still not fixed in android 9 (it was definitely working before and is working fine even now in other android versions). So, I am almost sure this is clearTextTraffic and file upload related issue (or at least related with targetSDK change). But not sure what or how to solve this. I am using okhttp. Any help is greatly appreciated.
Ok, that turned out to be android permission issue with FOREGROUND_SERVICE.
Apps targeting API Build.VERSION_CODES.P or later must request the permission Manifest.permission.FOREGROUND_SERVICE in order to use this API.
The solution is to add this line
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
in AndroidManifest.xml
Detailed answer here
Also, if anyone else have the issue with clearText error since you don't have an SSL certificate, Let's encrypt is a no profit certificate providing authority that provides free SSL certificate. Check here and here. You can use the software in second link to easily apply and install Let's encrypt SSL certificates in your server. Very easy.