0

When i accessed my app on the browser i have no problem accessing data from API. But when i launch it on emulator on android studio, i can´t. It pops-up a card with a ERROR CODE :0, Message Ht failure with the referent link API.

I tried to add the allow-intent, change the "localhost" on API GET request to "127.0.0.1"... and more that i don't remember.

Even the DATA received by the server side is not accessible. Right now i'm inclined to think that is a proxy related issue or a CORS problem.

jcmendes98
  • 148
  • 1
  • 10

3 Answers3

1

Problem Solved: Basically you need to change the url on your project where you do service. Change it from localhost:3000 to 10.0.2.2:3000. The 3000is the port's number, it doesn't need to be 3000. Then you open android studio, open emulator and run it. On the litle tab right next to the android device, theres 3 dots at the end. Press those, then go to settings, and change proxy to 10.0.2.2 and the port number to the one you are using, in this case is 3000. After that it will work. Sorry for late update on the problem! For more info: why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client

jcmendes98
  • 148
  • 1
  • 10
0

This can sometimes be caused by the emulated device looking at itself, not at your machine. Are you looking at it from the emulated device browser, the Ionic Devapp on emulated device, or built to native on the emulated device? Set any urls on the device to point to your host machine external IP, and allow open networking on the emulated device.

Tobin
  • 1,698
  • 15
  • 24
0

I had this error and searched for days. I have sorted out using capacitor and not cordova. Launch this command from the project folder:

ionic build

ionic capacitor add

npx cap open andoid

If last command gives error, open the android folder with Android Studios 4

Pietro
  • 127
  • 6