Issue
I made a game using Unity for Android versions >= 6.0. The game runs well in versions < 9.0, but I have a problem with my Unity Game in Android 9.0.
I explain what happens: When the game starts for the first time, the player must login or sign up in the game (connecting with the database in the server). But in 9.0, when you run the game and choose one of those 2 options and touch the button to login/sing up, a message (which I made to notify the user that game cannot connect to the server because a network problem) appears.
What can be the cause of the problem? Maybe it is because of network permissions in Android 9.0?
Pd: I'm using http to connect to server.
Looking Google Console, I have 3 warnings:
The following APIs are on a gray list and Google cannot guarantee that they work on the available versions of Android. It is possible that some of them are restricted in your target SDK.
This can be the problem because the game cannot do a request to the server?
Solution
I also had same problem. I solved problem using below code
create new file network_security_config.xml
under xml resource directory.
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
And in AndroidManifest.xml
file
<application
..............
android:networkSecurityConfig="@xml/network_security_config"
....... />
</application>
Answered By - Chirag Savsani
Answer Checked By - Pedro (JavaFixing Volunteer)