Ionic3 + HTTP call + Android 9.0.4

Hello friends,
Please help me

HTTP call fail in Real device (Android 9.0.4) in other Android version it is working fine.

my system info:


Ionic:

   ionic (Ionic CLI)  : 4.4.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.3
   @ionic/app-scripts : 3.2.1

Cordova:

   cordova (Cordova CLI) : 9.0.0
   Cordova Platforms     : android 8.0.0, browser 6.0.0, ios 5.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 8 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/infosenseglobal/Library/Android/sdk)
   ios-deploy        : 1.9.2
   ios-sim           : 7.0.0
   NodeJS            : v8.11.1 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : macOS
   Xcode             : Xcode 10.1 Build version 10B61

Output:
image

6 Likes

+1 here
Joining the queue looking for a solution
Ionic:

ionic (Ionic CLI) : 4.4.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.3
@ionic/app-scripts : 3.2.1

i have latest Android SDK,
i have tried uninstall whitelist plugin and install it.

but still issue is there.

1.Check it with Native HTTP
2.Check for CORS

1 Like

same issue. fails on android 9.0 but works fine on other versions of android and web browsers

2 Likes

I had the same problem and was able to solve - but not in a safe manner. It looks like that starting with Android 9, ClearText support is disabled by default. I read that in this link . To change that in ionic, you need to add this line on config.xml, inside platform name=“android”

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>

If the error persists, I recommed you use chrome dev tools to debug an Android 9 device. Connect the phone via usb, go to developer options enable usb debug and then, go to chrome on the pc and search chrome://inspect . You’ll be able to see the error.

2 Likes

Had the same problem open your config.xml

add:

<platform name="android">
...
        <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>
....
    </platform>

But this is not enough, as this will just give you a build fail, also add

xmlns:android="http://schemas.android.com/apk/res/android"

in your <widget tag at the top should look like this

<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">

5 Likes

Thank you @JGFAlmeida and @av_virgil, your suggestions solved my problem too: ([SOLVED]HttpClient doesn't work on a Huawei device. Compatibility problem? - #4 by ioclaudio).

According to you will I have the same problem on iOS devices?

cld

I didn’t got this problem on ios. I supose it will work just fine for you as well.

1 Like

i have same error can you help me

Hello All,

i have found one temporary solution for this Error, and it is working fine with my app,
and i have tested it with multiple devices and multiple apps.

Solution is

please put this link with your API/Web service link
https://cors-anywhere.herokuapp.com/

for example :
my API/Web Service URL is = “http://api.abcd.com/userList”

my new URL is = “https://cors-anywhere.herokuapp.com/http://api.abcd.com/userList”

Thanks.

4 Likes

I have same configuration and facing the same problem. But I get the CORS error only when I install and launch the app for the first time.

It works fine after killing and re launching the app.
I have tries rhe edit config fix it solves clear text issue but CORS error still persists.

Any help or suggestion is highly appreciated.

Nice!!!
You cant use https://letsencrypt.org/ to generate free SSL on your own server.
:wink:

1 Like

@VasuNagpal I expect your issue is to do with the bug in the latest version of Chrome ? https://bugs.chromium.org/p/chromium/issues/detail?id=991107

1 Like

hi @richardshergold
not in chrome.

This apparently happen due to no SSL certificate.
xmlns:android="http://schemas.android.com/apk/res/android"
was enough to work here

Try this it wil work for you.

<preference name="usesCleartextTraffic" value="true" />

Same problem with ionic 3 app and Android 9. Trying solution…

can you say where put this line?

Hola @derman10 esa linea la colocarias en en archivo config.xml, fijate q existen varias lineas q empiezan con la etiqueta

<preference name=“algo” value=“algo” /

antes de la linea

<platform name=“android”

2 Likes