Background Info
I got a Samsung GT-S5830, running Android 2.3.4. The device has been successfully rooted.
I edited the WIFI settings to connect to my home network, so now I can surf the Internet event though there is no simm card. The network configuration is static, as follows:
IP : 192.168.0.7
Mask : 255.255.255.0
Gateway : 192.168.0.1
DNS1 : 192.168.0.1
In my local machine, I've installed the Android SDK tools (ADB).
From that console, I issue the following commands:
1) C:\> adb shell
2) $ su
3) # (now successfully logged as root)
Once I am logged in as root (the symbol # is showing), I can successfully ping the following addresses:
192.168.0.7 (the handheld address)
192.168.0.1 (the gateway)
127.0.0.1 (loopback)
I also can ping intranet sites such as Google or FB
The problem
However, I can't ping any other machine in the intranet, eg 192.168.0.4, which is one of my local servers.
The command netcfg shows the following information:
Did anyone had to face the same problem?
Many thanks for your help.
Well, I couldn't work out what's causing the problem, but I've found a workaround.
Although the device is connected to the intranet, it make the requests from the 'outside'. As you can see in the screenshot above, the network adaptor isn't anything like 'eth0' but 'wlan0'. In other words, it's searching for the public IP of the web server
What I did is to configure the firewall to accept inbound traffic on the port 80 (web). Doing this way, I was able to render my webpages on the device.
Related
appears after running react-native run-android
I click the reload JS button and it changes to
Which is more informative, I am using VS standalone Android Emulator, and have already ran adb reverse etc etc
I do not see an option for Debug server host & port for device in Dev settings like it says there should be.
This happens when you haven't set the server IP (which should be on the same local network as your phone).
From your question I assume you can connect to the emulator using adb then you should be able to send command to it using the following according to the official guide pointed out by G. Hamaide:
adb shell input keyevent 82
This should send open menu event to the emulator and show you the menu where you will find Dev Settings and if you open it there you will find Debug Server host & port.
In order to connect to this server you must be on the same local network (i.e. connected to the same router). I assume you are using default options on a Windows machine so open a cmd shell and learn you local IP address using ipconfig. You can now set host and port to YOUR_LOCAL_IP:8081 (default port is 8081). Try to reload and it should work now.
You need to follow the steps from their official guide.
From where you are stuck follow these steps :
Open the Developer menu by shaking the device or running adb shell input keyevent 82 from the command line.
Go to Dev Settings.
Go to Debug server host for device.
Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081). On Mac, you can find the IP address in System Preferences / Network. On Windows, open the command prompt and type ipconfig to find your machine's IP address (more info).
Go back to the Developer menu and select Reload JS.
New to Android, I have .Net webservices residing in my PC. when my Android application calls the webservice from emulator with IP address, it runs perfectly.
But running the same code in mobile does not work (mobile is connected to PC using USB cable). It shows server timeout error. Both phone and PC are on the same network.
I am unable to run - adb pull /data/anr/traces.txt. It says unrecognized command. I had Android studio installed but unable to find adb file.
So installed Android Sdk again: C:\Program Files\android-sdk-windows\tools - it says that adb file has moved to platform-tools. I tried various ways but no luck.
Any suggestions are welcome. Many thanks in advance.
If your web service is not hosted, you need to use localhost or 127.0.0.1 in your mobile app's URL IP address. Make sure they are in the same network
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
here is any configuration for this tools eclipse or wamp or android sdk to connect my mobile phone to wampserver?
i look this exemple in this site blow i just copy and paste the code in eclipse but the problem is how i can import and export data from my phone to database and Conversely ?
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
If I've understood correctly, you're running a wamp server locally on your computer and you'd like to access that server from your application. The general approach is similar to connecting to any other server, but you'd have to find the right IP-address to connect to. Try this:
First, make sure your server is up and running.
Second, access the server on your computer using one of two addresses:
If you're testing your app on the emulator (AVD), use this: 10.0.2.2, which translates to the localhost-address on your computer.
If you're testing your app on an actual device, you'd have to find your computer's IP-address. On linux, open a terminal and execute the command ifconfig. In windows, I believe it's ipconfig. Use the address listed under wlan0 -> inet addr.
Remember to append the port number your server is running on.
EDIT
Example, given port number is 80:
Emulator: 10.0.2.2:80
Device: 192.168.X.X:80
I am currently somewhat struggling to get the Android emulator to use a custom DNS server, which is running on localhost (127.0.0.1).
As of now, I have tried various approaches trying to convince the emulator to use my DNS server, so far without success. In the end, it always boils down to the following error message:
### WARNING: can't resolve DNS server name 'localhost'
### WARNING: will use system default DNS server
localhost, however, resolves correctly when supplied to nslookup:
$ nslookup localhost
Server: dnszrh01.xxx
Address: 10.xxx.xxx.xxx
Non-authoritative answer:
Name: localhost.xxx
Address: 127.0.0.1
Using the IP address instead of the hostname also does not help much,
it just changes the error message to:
### WARNING: can't resolve DNS server name '127.0.0.1'
### WARNING: will use system default DNS server
The extra command line I am using to start the emulator reads:
-http-proxy http://proxy.xxx:8080 -dns-server 127.0.0.1 -debug-proxy -verbose
This is happening with Android emulator version 5.0 (build_id
ECLAIR-24846) running on Windows.
Any hint how to get this working is much appreciated!
A couple things...
1) I've noticed I get this error also when I have no network connectivity at all. ie. No wireless or ethernet connection.
2) Excerpt from Emulator guide:
http://developer.android.com/guide/developing/tools/emulator.html#dns
Configuring the Emulator's DNS Settings
At startup, the emulator reads the list of DNS servers that your system is currently using. It then stores the IP addresses of up to four servers on this list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, 10.0.2.5 and 10.0.2.6 as needed.
On Linux and OS X, the emulator obtains the DNS server addresses by parsing the file /etc/resolv.conf. On Windows, the emulator obtains the addresses by calling the GetNetworkParams() API. Note that this usually means that the emulator ignores the content of your "hosts" file (/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS on Windows).
When starting the emulator at the command line, you can also use the -dns-server option to manually specify the addresses of DNS servers to use, where is a comma-separated list of server names or IP addresses. You might find this option useful if you encounter DNS resolution problems in the emulated network (for example, an "Unknown Host error" message that appears when using the web browser).
3) Also see this other StackOverflow question:
Android emulator doesn't use Windows host file?