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.

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hello, I am trying to find this setting in ionic 5 but I don't know where it is. Any ideas?
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.

2 Comments

No, i just open a emulator on android studio and run ionic cordova run android --emulator .
I can´t acess either localhost or external API
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.