Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Wednesday, August 5, 2020

Android emulator not recognizing localhost

While configuring Google as an authentication provider for a react native app, I had to configure the redirect uri, which usually points to localhost.

However, the android emulator could not figure out the redirect uri, and that's because the android emulator and my PC are in different networks. localhost works on my PC, but the android emulator is its own network. The way to fix it is with adb reverse. Like this:

adb reverse tcp:44371 tcp:44371

The port number does not necessarily need to match, it can be different. The first port is the emulator's, and the second port is obviously your PC.

Saturday, July 18, 2020

Connecting to IIS Express from an Android emulator

I've been struggling with this. While working on a proof of concept of an Android app connecting to an API running in my localhost, the Android app could not to IIS Express. At first, I thought it had to do with using a self-signed certificate. But even without SSL I still got a network error. This is how I fixed it:

1) First, the Android app should connect to the local ipv4 address, not localhost, not 127.0.0.1

2) Modify the file applicationhost.config as indicated here https://blogs.blackmarble.co.uk/rfennell/2012/11/06/using-iisexpress-for-addresses-other-than-localhost/, by replacing localhost with *

3) Restart IIS Express

And that's it!