Android Emulator No Internet when using tethered iPhone - android

I've been struggling with this for a couple of days.
My Android Emulator does not have access to the Internet on Mac OS X when I use my iPhone's tethered Internet connection. I often use this connection whenever working on the go, so it's quite frustrating when it doesn't work.
I've tried the following:
Setting DNS and running emulator from command line.
./emulator -avd Pixel_2_API_26 -dns-server 8.8.8.8
Removing network connections except the tethered connection from Mac OS Networking.
Deleting and reinstalling the AVD.
Looking at the logs, the only networking related errors I get are:
D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_FALLBACK http://www.google.com/gen_204 Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
I/qemu-props: start adbd ...
and
D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_DNS www.google.com 78245ms FAIL
D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_HTTPS https://www.google.com/generate_204 Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
D/ConnectivityService: NetworkAgentInfo [WIFI () - 101] validation failed
D/WifiStateMachine: NETWORK_STATUS_UNWANTED_VALIDATION_FAILED
I feel like the simulator is still trying to use WiFi even though the WiFi device has been removed.

Related

Unable to open connection to: localhost/127.0.0.1:5037, due to: java.net.ConnectException: Connection refused: connect

My Android Studio 3.4.1 shows the error below (as in screenshot) when running the app
Unable to open connection to: localhost/127.0.0.1:5037, due to: java.net.ConnectException: Connection refused: connect
I have my android phone connected to my Windows 7 PC, but Android Studio still show the error. I did click on "Restart ADB server" but problem persists.
Thank you
Use 10.0.2.2 to access your actual machine.
When you use the emulator, localhost (127.0.0.1) refers to the device's own loopback service, not the one on your machine as you may expect.
You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development. You can read more from Here
Also, remember to access localhost from your real device your system and mobile need to connected to the same wifi/network.
I had the similar problem on Ubuntu: but I found out also that my phone keep reconnecting in IDE.
Solution - just to give permission change things to the android studio folder.

Unable to load application in Android Studio emulator

I can't open the application I'm developing in Android Studio emulator, It is showing the following message in the log
Could not open Selected VM debug port (8700). Make sure you do not have another instance of DDMS or of the eclipse plugin running. If it's being used by something else, choose a new port number in the preferences.
Unable to open connection to: localhost/17.253.38.253:5037, due to: java.net.ConnectException: Operation timed out
Following is the port listening by adb
adb 14528 unnikrishnan.b 10u IPv4 0x7e537943f4599ac9 0t0 TCP localhost:5037 (LISTEN)
This happened after I upgraded to android studio 3.1.2. How I can fix this issue?
Thanks,
Unnikrishnan B.
can be caused by an ip address in the file etc / host, sometimes you enter an additional to make tests and it is not deleted, you must check that in your file this
127.0.0.1 localhost
255.255.255.255 broadcasthost
:: 1 localhost
you can also ping the address 127.0.0.1 to check for an answer, $ ping localhost
additional information that can helps you
https://issuetracker.google.com/issues/37126279

Making Http Request to Local Computer from Android Emulator

I am using Visual Studio Emulator for Android. I have checked the network settings on my virtual android. My Desktop Adapter is 192.168.0.3 the other is 169.254.80.80.
I have tried in my config all three connections other posts have mentioned. This is not a duplicate because these three do not work.
http://10.0.2.2:52930/api/values/5
http://192.168.0.3:52930/api/values/5
http://169.254.80.80:52930/api/values/5
I have verified my service is running and can be accessed from my local computer with http://localhost:52930/api/values/5
The error for 10.0.2.2 connection and 192.168.0.3 is
{"originalStack":"Error: java.net.ConnectException: failed to connect to /10.0.2.
2 (port 52930): connect failed: ENETUNREACH (Network is unreachable)\n at ZoneAwar
eError (file:///data/data/org.nativescript.Groceries/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:
993:33)\n at onRequestComplete (file:///data/data/org.nativescript.Groceries/files/app/tns_modules/tns-core-modules/http/http-r
equest/http-request.js:44:34)
There is a much longer period of wait (about 2 minutes) before the 169.254.80.80 connection begins to show the above error.
I have disabled the windows firewall. I have no other firewalls. I have allowed Hyper-V application in the firewall just in case.
Any other suggestions?
EDIT
It appears to be an issue with the emulator. I opened up the browser in the emulator and typed in http://headers.jsontest.com
And it appears that it can't access that url. The error the emulators browser is reporting is.
Webpage not available.
The webpage at http://headers.jsontest.com/ could not be loaded because:
net::ERR_NAME_NOT_RESOLVED

Android 127.0.0.1 (loopback) connection: Works on WiFi, fails with 3G/4G

My application embeds a local http server that can be accessed through the loopback device at URL: http://127.0.0.1:8080/
It works fine with WiFi enabled, it also works fine with no external network (no WiFi, no 3G) but it fails when WiFi is disabled and 3G enabled.
Connecting through adb shell and executing "netcfg" I can see that the loopback device is always enabled:
shell#android:/ $ netcfg
...
lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
...
Alos "ping 127.0.0.1" continues to work while switching on/off the WiFi or 3G.
Any idea?
UPDATE:
Adding to the puzzle. From my dev computer I forward the tcp port:
$ adb forward tcp:8080 tcp:8080
Then I try to connect from my PC using http://127.0.0.1:8080/. It works, but when it continues to fail when using a browser running on the android device.
UPDATE 2015-06-01:
When working on 3G I see on adb logcat lot of related errors similar to:
W/ContextImpl( 504): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendStickyBroadcast:1239 com.android.server.TelephonyRegistry$3.onReceive:818 android.app.LoadedApk$ReceiverDispatcher$Args.run:788 android.os.Handler.handleCallback:725 android.os.Handler.dispatchMessage:92
and
E/CellLocation( 8336): create GsmCellLocation
It doesn't make any sense to me to trigger Gsm activity to connect to the loopback device.
UPDATE 2015-06-01 (2):
I managed to install wget in
/data/data/com.XXXX.yyy/files/appFiles/bin
Then I connect through "adb shell" -> "run-as com.XXXX.yyy" and finally execute:
wget -O - "http://127.0.0.1:8080/"
I works properly so I can discard any weird security setup that disables loopback access on localhost, so I guess it has something to do with WebView/WebViewClient trying to wrongly use a 3G external proxy to access the loopback. Now I'm wondering whether it's possible to disable the proxy on WebView.
Finally it looks it was a problem with the WebView trying to access an external proxy even for the lookback interface. I fixed the issue following the solution proposed at: WebView android proxy

Getting "Launch error: Failed to connect to remote VM. Connection timed out" when trying to debug my app on my device in android

I tried all the possible options given on net and on this site, but none of them worked.
I am getting:
Launch error: Failed to connect to remote VM. Connection timed out.
when I am trying to debug my application on my mobile device.
the application runs properly with out any issue when I am running normally
I have used at lease these links by now:
How to resolve "Waiting for Debugger" message?
Eclipse issue - Launch error: Failed to connect to remote VM. Connection timed out
Eclipse Error: "Failed to connect to remote VM"
Launch error: Failed to connect to remote VM
https://forums.oracle.com/forums/thread.jspa?threadID=653343
None of the above seem to work.
Go to Window -> Preferences -> General -> Network Connections, and check if there is any proxy set here, change the 'Active Provider' to be 'Direct' and try again.
I dont know why, but this works for me:
First Run(or Debug) your application in an emulator and then Debug the application on the device (without closing the emulator).
let me know if this works for you.
I've been having the same frustrating problem. I finally found something that is working for me: making sure localhosts is being resolved correctly (and really explicitly).
Test to see if it works when your development machine is not connected to the net (no WiFi, no network cables). If it does work under those conditions, then it may be that you need to make sure that addresses are resolving to localhost properly. The messages that DDMS and adb.exe use for debugging and communicating to the VM must properly resolve to localhost on your machine. (Yes, it's odd that other commands using DDMS & adb work just fine but debugging doesn't. Seems that something in DDMS or adb needs to be standardized so they all work under the same conditions.)
If you need to make sure that things are resolving to localhost properly:
1) Make sure that this line is in your /Windows/System32/drivers/etc/hosts [windows] (or etc/hosts [*nix] file:
127.0.0.1 localhost
(you can have any amount of whitespace between "127.0.0.1" and "localhost")
2) If that doesn't work, then you may need to also add your PC's IPv4 address to the hosts file, and resolve it to localhost. (You can find out the IPv4 address for your machine with the ipconfig command.) If, for example, your machine's IPv4 address is 192.168.1.100 then you'd add the line
192.168.1.100 localhost
to your hosts file. (You can add it below the "127.0.0.1 localhost" line in the file.)
I had (1) in my hosts file but it still wasn't working (unless my PC wasn't connected to the net). I tried (2) on a bit of a guess, and that worked for me.
BTW: You can verify that adb (and your emulator if you're running one) is listening on ports by using the netstat -b command. (Note that on Win7 you need admin privileges for the -b option. I open a command window using "Run as Administrator.")
May seem like an obvious answer but make sure you don't have two emulators running - 5554; 5556; ... The debugger has difficulty setting the port when it doesn't know which one to connect to.

Categories

Resources