Alir Kahi
Alir Kahi

Reputation: 1300

Connect VS Android emulator to localhost

I'm developing a Xamarin.Forms 4 application with Visual Studio 2015 update 3 on Windows 10. Now I've setup an ASP.net web API and I'm trying to connect to it when it's been run on localhost with VS Andorid emulator 1.1 for Kitkat 4.4 (Andorid 4.4 API 19). Although my app works with the Windows Phone emulator, it doesn't with the Android emulator.

I've tried to connect to the 10.0.2.2 or 169.254.80.80 like it was suggested here but it doesn't work neither from the emulator nor the device itself. I've also enabled IIS express to accept request from external devices with the second solution provided here so I'm out of ideas.

Please elaborate on your answers as it seems that a lot of people are running into the same issue.

Thanks a lot in advance!

Upvotes: 0

Views: 1703

Answers (2)

tlagreca
tlagreca

Reputation: 365

I had been on a mission for days trying to solve this. Screwing with ports and the iis bindings. But I found this

https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

This package creates a psuedo URL that exposes the localhost:[port] to the emulator.

Troubles be gone.

Upvotes: 1

Maxim Alexeyev
Maxim Alexeyev

Reputation: 1031

Don't forget to run Visual Studio as Administrator. I had similar problem until I ran it as Administrator.

Also, I like more how the solution is described here: http://briannoyesblog.azurewebsites.net/2016/03/06/calling-localhost-web-apis-from-visual-studio-android-emulator/

Upvotes: 1

Related Questions