I have created a back end in Ruby on Rails and I am using url http://192.168.1.6:3000/products/4.json
where my phone is running with ip on the same gateway. http://192.168.1.somethign When I try connecting from android it gives the error unknown host exception. I also tried 10.0.2.2, which gives the same error. i tried running this url from the phone browser, and it says the webpage is not available. The phone is connected to the system using USB, both are in the same network using same wifi, I have also given the uses permission to access internet in the manifest file. How do I give the url now?
It is unable to resolve host, so I'm not mentioning the code, i shall add it if that helps.
After excessive searching and realizing the problem was not with the code but the reason was inability of phone and laptop to communicate properly. Still I could not fathom why? though they were in the same WiFi network. I solved my problem using this method . Putting it here for others reference,
1) Turn on the hotspot of your android phone
2) Connect your laptop to that network.(the hotspot).
3) Check the ipaddress now using ipconfig
4) Proceed using this ip address
Related
I remember with another phone I was able to debug my local website dev, now there is a problem preventing me to open localhost in my mobile and cannot find how.
Looking at:
Google Chrome for Android Remote Debugging - "localhost:9222" Not Available
my phone is connected, on localhost:9222 I can see a list of tabs.
I can access tabs loading site from remote, but cannot load my localhost.
In one case, error displayed:
408 - Timeout.
On another , simply chrome display site is not reachable.
ERR_NAME_NOT_RESOLVED
I tried both with port-forward enabled as well as not (if enabled, listening to 8081, 8080).
Phone is connected via USB but seems cannot reach my localhost address of the laptop, still on same wifi spot.
EDITED
I remember with another phone I was able to debug my local website
dev, now there is a problem preventing me to open localhost in my
mobile and cannot find how.
I was doing with Bonjour- the "Bonjour host" is the name Mac assign to your user machine user.local. I was able to connect former android host, but now it cannot be solved anymore unless of IP.
The two devices should be on the same network and it won't be localhost in that case, but you have to replace localhost with the IP of the server PC!
So instead of localhost:9222, it would be 192.168.1.10:9222 giving that 192.168.1.10 is your IP address!
Volley service is running on emulator correctly but not on real device? I have also change localhost to my IP address?
I have also tried for increasing volley request time but still not solved with this issue.
Just try to be more specific with the question.
If you are using local host
- just try to connect the phone to the computer and try to compile the app check its working or not
try to access the url from the browser check its accessible
This will run your app on device connected.
Enable USB debugging on your device by going to Settings > Developer options.
click on run and select your device.
The problem is with the URL that you are sending requests to.
If you have your device connected to your system via USB, try
http://10.0.2.2/myserverfile.php
else if your server is somewhere hosted online, use http://www.myserverlocation.blah/myserverfile.php
I was running my application fine.There were some changes in the network,like my router and internet connection got changed.Suddenly in the LogCat,I see an error like connection refused.I have provided the static IP still I get the same error.
I am running my server on my laptop and the app on the device. Intially I was able to access the application through the app and also through the browser.Can you guide me and does my Android device needs a new setting that I am missing?
Definitely, you faced some networking problem. So, the diagnostic is the same as for any connected device.
check local Android firewall - try to connect to some another server, like facebook.com or google.com
check your laptop firewall settings
draw your network schematic carefully and think what should be working and how
try tcpdump\wireshark to see what's actually going on the wire
Hope you win!
Well the static IP works not sure why it was not working before may be because I was using a LAN connection only for laptop not a same WIFI connection both for laptop and android device.
I have a Tomcat server running on Localhost. My app can access it in the emulator using 10.0.0.2:8080. But when I connect a device it can't access the server.
I've seen some similar questions but couldn't get this working. can someone give me the steps on what to do?
we use 10.0.2.2:8081 because 127.0.0.1 is reserved for the emulator, however, when you need to try the application through a real device you need to change the URL to your PC IP
go to CMD and run ipconfig, look for IPv4 address, this IP you will use it..
add it to the URL for example: http://192.somethin.somthin.somthing:8081/the-location.php
P.S: you should set your firewall off and turn off any antivirus
The device may not be on the same network as the Tomcat server. Does your network provide VPN access? If so, try installing an Android VPN client (Junos Pulse is a good free one). Connect your device to VPN and try again.
10.0.0.2 looks like an internal address. The emulator is likely able to connect because the machine on which it is running is connected to the network. The actual device needs a direct connection as well. VPN should solve that.
I made an app that connects to a php file. The code is working using the AVD without a problem. Now when I tried the app in my android device it force closes. My android device is connected through a wifi network. I'm using wamp server on windows 7.
I have pinpointed the problem but I cannot resolve it. I'm hoping one of you good guys can help me.
This is my culprit (192.168.1.100 is the machines IP):
private static String url_all_products = "http://192.168.1.100/android_connect/get_all_products.php";
How can this be solved? 100% working in AVD but won't work in actual android device.
#droidH if you working on local server change your url to 10.0.2.2 to your IP address
go to this link it works
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
You need to check two things :
Your external IP address i.e if you are using windows use command
"ipconfig" and get IPv4 address.
Check you permissions in AndroidManifest :
uses-permission android:name="android.permission.INTERNET"
Also check : https://stackoverflow.com/a/16510143/644011
Do this:
first, put both your android device and your computer into the same network as described here
then, make your device connect directly to your computer via its IP in that network (find the IP as here)
Try to connect your mobile to the same network as your computer.
I used virtual router to make my mobile in same network as my laptop
Then use ip address of your computer to access your computer web server from your mobile.