This simple fetch always worked fine on my published app (SDK 26), since I rebuilt the app using SDK 28 (32bit). Since then it does not work on devices with Android 9 and it reports “connection error”. On other versions of Android (6, 7, 8) it works perfectly.
Unfortunately I don’t have a Android 9 device to do any test.
I’m getting a lot of 1 star reviews because of this issue…
Yep, its the SSL(https) connections in Pie, it looks like you can specify non-secure domains for “clear text traffic” through adding Network Security Config to your manifest:
Yes, I may confirm that now Google wants HTTPS connections. I purchased and installed a SSL certificate for my VPS, published a updated version of the app and now it works. Unfortunately in three days I got more negative reviews regarding this “network error” than all the other positive reviews.
<Require Condition="Android" Gradle.BuildFile.End>
<![CDATA[
// define the task
task updateManifest(type: UpdateManifestTask)
// implement the task
class UpdateManifestTask extends DefaultTask {
@TaskAction
def update() {
// find the manifest and get the contents
// TODO: use gradle to find manifest path based on variant/flavor
def manifestPath = "app/src/main/AndroidManifest.xml"
def manifestFile = new File(manifestPath)
def content = manifestFile.getText()
// update content, in our case, find and replace some string
def updatedContent = content.replaceAll("<application ", "<application android:networkSecurityConfig=\"@xml/network_security_config\" ")
manifestFile.write(updatedContent)
}
}
// make processDebugManifest task depend on our new task to ensure the manifest is updated when it's needed
afterEvaluate {
processDebugManifest.dependsOn updateManifest
}
]]>
</Require>
</Extensions>
To add android:networkSecurityConfig="@xml/network_security_config" to the manifest.
And a network_security_config.xml file (you can edit this file as your demand):
Thank you Cristian.
Do you mean that I have to create a empty .UXL file and simply add the above <Require> condition and then create a .XML in the same folder of the .UXL file?