I've been following the tutorial in Creating an Endpoints Backend from an Android Project. Everything is being compiled and looks promising. The backend is up.
I changed CloudEndpointUtils#LOCAL_ANDROID_RUN
to true
. But when I try to test the app on a real device (not emulator) I'm failing on:
java.net.SocketException: failed to connect to /10.0.2.2 (port 8888) after 20000ms: isConnected failed: EHOSTUNREACH (No route to host)
So I looked at CloudEndpointUtils
and saw that setting LOCAL_ANDROID_RUN
to true
makes the app look for DevAppServer in http://10.0.2.2:8888
, which is the emulator virtual router.
But I'm not using the emulator. So I tried to change the constant holding this url to http://127.0.0.1:8888/
but still no luck. I'm now failing on:
java.net.ConnectException: failed to connect to /127.0.0.1 (port 8888) after 20000ms: isConnected failed: ECONNREFUSED (Connection refused)
I thought it might be because my PC is behind a firewall, so I disabled it, but still nothing.
Any suggestion would be appreciated.
If you want to do this in Android Studio, set httpAddress as follows in your build.gradle
appengine {
...
httpAddress = "0.0.0.0"
}
To accomplish this
2.(Contniued) Go to Arugments -> add exactly like this
--address=0.0.0.0 --port=.......
*to get your ip address, go to cmd -> ipconfig -> add (IPV4 address with port number) in step 1
important note: Please change this everytime in case you are accessing internet from dongle or some dynamic IP internet service
Thankyou ... this works perfectly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With