Ionic/angular Android Http not working

This is not true, and IMHO the Angular HttpClient should be preferred over any other option unless you need SSL certificate pinning. It has orders of magnitude more eyes on it, and since it does more minutia for you, your app code is considerably leaner and easier to read.

That was my feeling too which is why I am at a loss as to why itā€™s not working on my Android device today.

Add to your androidmanifest.xml file in your android studio project this:

android:usesCleartextTraffic=ā€œtrueā€

in the application tag and let me know how it goes

2 Likes

Hi. Yes Iā€™ve tried that and it made no difference. This is so odd Iā€™m wondering if it could be an issue with the SSL cert on the server or something.

I use Qualys to troubleshoot stuff like that.

1 Like

I would suggest creating an empty android project and making a request to that same serverā€¦ You can also try an empty project with the itunes api and see if that worksā€¦ then work from there.

1 Like

Hi @eliasminima can you please show how to do this? What do you mean by allow cars in your json config file?

I am still having this issue on an Ionic 5 with Angular project. My http requests using the Angular HttpClient work fine on browser, iOS, iOS Emulator, and Android Emulator, but fails on Android devices.

For what itā€™s worth at this point adding android:usesCleartextTraffic=ā€œtrueā€ to the manifest file worked for me. I was having a similar problem where http worked from the browser but not the emulator in android studio or the android scanner itself. After adding the above line both places started working. I am using angular 12 with ionic beta 6 and capacitor. (and http from angular, not ionic)

2 Likes

Esto funcionĆ³ para mĆ­.


Muchas gracias

1 Like

this worked for me. my issue was that angular http client wasnā€™t working in emulator. i also had to aim at 10.0.2.2 instead of localhost