[SOLVED]HttpClient doesn't work on a Huawei device. Compatibility problem?

I have an Ionic4 app that calls some web services using HttpClient;

import { HttpClient } from '@angular/common/http';
constructor(private plt: Platform, private  httpClient:  HttpClient,...) {...}
  login(username, password) {
    const loginUrl = this.settingsManager.getBaseWsUrl() + '/auth/login';
    return  this.httpClient.post(loginUrl, {
      email: username,
      password: password

I’ve tried this app, with this code on some Android devices and it works well.
It works well in debug mode with Chrome.
Now I’ve installed this app on a Huawei device (Honor Play COR-L29 with Android 9) and on this device the httpClient call fails.
I can’t see the error, so I can’t understand what is the problem.
The device is online.

I’ve installed the Ionic Dev app on this device to try the app, but I can’t login because it seems that Ionic Dev too doesn’t reach the Network.
So, is it a problem between the network plugin of Ionic and Huawei?
Do you ever had this problem?
Are there any other tests I can do to debug the problem?
I have no idea.

Thank you very much


Have you tried remotely debugging the application whilst it is running on the device? See this video if you are unsure how: https://www.youtube.com/watch?v=Y1rD954ZyKA

Having the actual error that is occurring will help a great deal. Given the behaviour you’re experiencing it could be an SSL problem, Android treats secure requests different in debug/prod builds, and whilst your SSL certificate might appear fine there might be some hidden issues (e.g. not being able to verify the full certificate chain). You can check for any issues with your SSL set up using a tool like this: https://www.ssllabs.com/ssltest/

1 Like

Thank you for your suggestions, I’ll try.
However the URL used by my app doesn’t use SSL. It is a call to a simple http web service (for the moment).


Thank you @joshmorony for your suggestions.
Your tutorial is very interesting.
It can be used together with this one: Remote debug Android devices - Chrome Developers
to prepare the debug phase.


  • launching the command: ionic cordova run android
  • using the app on the phone
  • looking at the Chrome console on my pc

I’ve seen this error:
polyfills.js:5601 OPTIONS http://cccccccc/auth/login net::ERR_CLEARTEXT_NOT_PERMITTED

Googling a bit I’ve found these posts:

So I’ve added to the config.xml file:

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

and I’ve modified the top of the same file in this way:
<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">

And now it works.
The next step will be to move web services to HTTPS.

Will I have the same problem on ios?
I’ll let you know.



@ioclaudio @joshmorony I have edit my config.xml and http requests is working fine but background geolocation plugin stopped working . what’s is the peoblem ?

do you have any errors? You can run the app in debug mode and see if there are error message in Chrome.
Josh has posted some videos and tutorial on how to debug an Ionic app.


I did not receive any error . no errors appear and the plugin not working

@ioclaudio hey, ioclaudio.
My ionic4 development, config.xml has set the widget and android:usesCleartextTraffic=“true” , ​​but in Huawei still reported error, Failed to load resource: net::ERR_CLEARTEXT_NOT_PERMITTED

    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
        <application android:networkSecurityConfig="@xml/network_security_config" />
        <application android:usesCleartextTraffic="true" />

I don’t know if it is the right solution
But I added these lines to confix.xml:

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

I still report an error. :喜悦:

My network_security_config.xml generated by android is like this, yours? :pleading_face:
domain-config cleartextTrafficPermitted=“true”
domain localhost /domain

its working for me !! thank you

I don’t have this file.

good night, the problem is that when generating the apk and installing it on my android phone 9 the screen will start my application goes blank, I already did everything you have said about the update to sdk 28 but nothing that works for me does anyone know what I can do about it

which one is works for you can you share the code
i am facing the same problem

I found a solution.

First i added the lines in config.xml

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
  <application android:networkSecurityConfig="@xml/network_security_config" />
  <application android:usesCleartextTraffic="true" />

After that, go to resources/android/xml/network_security_config.xml and put the ip

<?xml version="1.0" encoding="utf-8"?>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true"></domain>
        <domain includeSubdomains="true">PUT SERVER IP HERE</domain>

This it’s working for my huawei P30 - Lite