0

I am developing an hybrid application using ionic. I use Ionic Box which is ran by vagrant (Virtual Box). I also use Genymotion as the emulator.

In my application, I authenticate using Google OAuth2. The configuration needs a redirect url callback which is setup to http://www.example.com/auth/google/callback for the development environment. If I setup an IP address I get the following error: Error: invalid_request device_id and device_name are required for private IP

In genymotion browser, I can access my application with http://10.0.3.2:8100. So I would like to be able to access http://10.0.3.2:8100 when typing http://www.example.com:8100. Access host from Genymotion emulator

How do create that mapping in Genymotion?

Vagrant Box:

vagrant@ionic-android:/project$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:f9:58:8e
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef9:588e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2459 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3188 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:196630 (196.6 KB)  TX bytes:4896919 (4.8 MB)

Genymotion Emulation is running on 192.168.56.101.

Community
  • 1
  • 1
Sydney
  • 11,964
  • 19
  • 90
  • 142

1 Answers1

1

The solution is to add an entry in /etc/hosts.

Get the hosts file on your local system

vagrant@ionic-android:/project$ adb pull /system/etc/hosts

Add an entry to that file

192.168.0.1 www.example.com

Remount /system as writable in case it's read only

vagrant@ionic-android:/project$ adb shell
root@vbox86p:/ # mount -o rw,remount /system
root@vbox86p:/ # exit

Read only file system on Android

Push the modified hosts file

vagrant@ionic-android:/project$ adb push hosts /system/etc
Community
  • 1
  • 1
Sydney
  • 11,964
  • 19
  • 90
  • 142