Ad

UnityWebRequest Not Working After Updating Android OS

The following used to work on both the PC Unity Editor and my mobile device:

        WWWForm Fields = new WWWForm();
        Fields.AddField("dummy","");
        UnityWebRequest www = UnityWebRequest.Post(Apis.internetTest, Fields);
        yield return www.SendWebRequest();

After updating the Android OS on my mobile device, it will always return an 'Unknown Error'.

So for now, my game would work on some older phones, but not on phones with updated Android OS.

I am Using Unity 2018.4.2f1. How can I solve this problem?

Reference: UnityWebRequest.

Apis.internetTest is:

http://quizjungle-app.com/internet-test
Ad

Answer

Google has enforced the use of HTTPS (ie. no more HTTP) on newer Android devices. That's why the connection broke for my case. I have solved it by adding [android:usesCleartextTraffic="true"] in the opening tag of < application> in AndroidManifest.xml in the android plugin directory.

Ad
source: stackoverflow.com
Ad