3

Server - WAMP

Host - localhost/127.0.0.1/10.0.2.2(emulators ip address for hosts local server)

App - android(frontend), laravel(backend)

IDE - Android Studio

Ive tried multiple things to resolve this issue, from turning off my firewall to creating a virtual host with both a named virtual host and with the ip address 10.0.2.2. through configuring the host file and editing both the http.vhosts.conf and httpd.conf files appropriately.

I have seen the following threads and none provided the solution

Connection to LocalHost/10.0.2.2 from Android Emulator timed out

How to connect emulator to laravel server localhost:8000

http://www.4answered.com/questions/view/20e0ab1/How-to-connect-emulator-to-laravel-server-localhost8000#videoAnswer

The Error looks like this -

09-03 17:42:37.886 23713-23739/com.geniusesafrica.geniuses   I/OpenGLRenderer: Initialized EGL, version 1.4
09-03 17:42:45.810 23713-23713/com.geniusesafrica.geniuses I/Choreographer: Skipped 476 frames!  The application may be doing too much work on its main thread.
09-03 17:43:06.820 23713-23713/com.geniusesafrica.geniuses D/MainActivity: onFailure: .failed to connect to /10.0.2.2 (port 8000) after 10000ms
09-03 17:43:06.826 23713-23713/com.geniusesafrica.geniuses I/Choreographer: Skipped 1259 frames!  The application may be doing too much work on its main thread.
09-03 17:43:06.829 23713-23782/com.geniusesafrica.geniuses D/FA: Connected to remote service
09-03 17:43:06.829 23713-23782/com.geniusesafrica.geniuses V/FA: Processing queued up service tasks: 1
09-03 17:43:11.867 23713-23782/com.geniusesafrica.geniuses V/FA: Inactivity, disconnecting from AppMeasurementService

And Here is the retrofit builder -

Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("http://10.0.2.2:8000/api/")
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();

I can access my laravel app from the Machines browser and from postman as well and i can make requests from my emulator to remote addresses.

On the emulators browser the same url is giving the following error -

 net:ERR_NAME_NOT_RESOLVED

then its timing out with a

 net:ERR_CONNECTION_TIMED_OUT

Any help will be appreciated.

Community
  • 1
  • 1
Joshua Majebi
  • 848
  • 4
  • 11
  • 30

0 Answers0