- Home /
The question is answered, right answer was accepted
HTTP Requests removed on Android Pie (API 28+)
Hello, i have an app which needs HTTP requests to my server to work, and it works fine on every device(iOS and Android) except Android 9.0 Pie (API 28+), and i can't get it to work. After some research i found that Google had removed HTTP connections by default on Android Pie due to unencrypted and security reasons, but there is a way to set it only for my domain, but to do that requires to edit the manifest file, and to add an extra XML file, but i have no clue how to do it on Unity. Im using the latest stable version of Unity 2018.3.5f1. Here is the default code i use for HTTP requests :
IEnumerator UpdateCheck() // Get updates
{
using (WWW www = new WWW("http://example.com/update.php?"))
{
yield return www;
print(www.text);
}
}
Thanks!
For me, just put the "S" solved the problem.
USE "http*s*://" instead "http://".
Answer by hydrox1 · Mar 18, 2019 at 07:33 PM
Well i have solved the problem without needing extra TLS certification for my server, all you need to do is firstly when you build the APK, check the 'Export Project' so it will export files ready for Android Studio. After finishing it open it up on Android Studio, and go to the manifest file and add the line android:usesCleartextTraffic="true"
and build the APK from Android Studio. And the Android system won't block the HTTP traffic anymore. I hope this will help someone!
thanks, this indeed resolved my problem. I had used HttpURLConnection rather than HttpsURLConnection on Android 9.0 Pie. Once the replacement happened, all my question cleared.
Follow this Question
Related Questions
why does UnityWebRequest want Dispose() ? 1 Answer
Server-Side Events with UnityHTTPWebRequests (text/event-stream) 0 Answers
UnityWebRequest not working junt in Android with unity 2018.3.x 2 Answers
Is HttpWebRequest supported for desktop and editor? 2 Answers
Unable to call external API (IBM Watson) via HTTP request? 1 Answer