React Native: Dev Server IP iOS vs Android - android

I'm running a DEV server locally on my Mac and want the mobile simulator to connect to it. After trying a few different things, I realized that iOS works fine when connecting to my server # http://localhost:8080/api but Android requires my IP Address like http://192.168.1.105:8080/api. Is there a way to make localhost work on Android as well?

In Android the localhost refers to the device on which the code is running, in this case the emulator.
If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead. You can read more from here.

Related

How can a client on a mobile device connect to localhost with a server running on a PC?

I have a big problem because I have a pc with a little amount of RAM and I can't use my RESTlet server on Eclipse and an Android client on Android Studio together... I read on the internet some solutions at my problem but maybe I wrong somethings because it doesn't work. How can I use the localhost (with or without the cable is the same) with my pc (for the server) and my phone (for the client) to debug and use my project?
Check out ngrok. It's a great addition to any developer's toolbox.
This app allows you to make your localhost accessible to the internet through a secure channel.
You'll download a small application for your PC, which will then give you a temporary and random URL, through which you can access the web server on your local machine.
This way, your phone will be able to reach your PC over WiFi, cell data, etc. You just need to have a way to configure the destination URL in your phone app to set it to the URL that ngrok gives you.
Another solution would be to create a Windows VM on any of the Cloud providers (such as AWS, Azure, Google, etc.), remote desktop into that machine, install Eclipse, copy your code and and run your API server there. And then use your own PC to run your Android simulator and point the destination URL to your VM's IP or domain name. This solution would be somewhat more complicated to set up and will require you to move your code around, expose the right ports, install a bunch of software on the VM, etc. Not to mention, this will probably cost you a little bit of money. So for testing and debugging purposes, that ngrok solution should work great.
In your url instead of "localhost" copy and paste your PC ip v4 address.You can get it on Windows from command prompt ipconfig command

How to browse the localhost on android device?

I try to browse localhost on my samsung device. I connected my device with eclipse via wifi. browsing http://192.1.1.190 I get a "Page not avialable. I remember, some days ago it worked
but on the emulator I am able to browse localhost.
I searched on google not able to find the correct ideas.can any one know about this.
any ideas? regards
I am currently building an Android app on the side and struggled with this problem. One solution here would be to connect your Android phone to a WiFi network which your Android Studio is also connected.
Then, when you debug your app from Android Studio, the phone should be able to access the IP address corresponding to localhost.
Yes i connect android device with wifi.but my laptop wifi ip and device ip is showing different ip numbers.so i cant able to access the localhost on android device especially.

How do I connect an Android Emulator to localhost server?

I have an ASP.NET/Azure application running on http://localhost:4617. I would like to debug a REST call made from an Android emulator. Related SO threads seem to indicate that you should use 10.0.2.2. I've tried several variations like http://10.0.2.2:4617, but none seem to work. Any other suggestions?
If I do ping localhost on my machine, it returns Reply from ::1: time<1ms which seems to have something to do with an ipV6 address, but I'm not sure how this is related.
If the local host is running on your desktop than that is the problem.
When you type http://10.0.2.2 it tries to connect to the Android emulator local host.
What you need to do is find your computer IP address (you can use google for it). Then once you have it type that into your android emulator browser and it should work
I was able to figure this out. If you're running an Azure server-emulator, then you need to run Visual Studio with administrator privileges. If you don't, then it will not bind correctly to the local host.

Connecting to host from Android via USB

Okay so here is the background of this problem. I commute a lot on the train and build a lot of PHP web apps optimized for mobile devices. I would like to develop code on a netbook (Running Ubuntu Server) with no GUI. All development done using Vim directly on the netbook.
I would like to connect up my Nexus 4 to the netbook via USB and "connect" to the netbooks web server in the chrome browser. I can only use USB for this since I won't be having any reliable internet access.
I understand that using adb from the Android SDK, you can forward a port from the netbook to the phone. However, I need to do it the other way around.
For example:
Run a web server on the netbook on port 4000
Connect phone via USB
Somehow forward port 4000 on the phone to port 4000 on the netbook
Open chrome browser on phone and go to localhost:4000.
I am aware of the "reverse port forwarding" method that is described in the Google docs at https://developers.google.com/chrome-developer-tools/docs/remote-debugging. However, this requires an installation of chrome on the netbook. I don't want to have to install an entire GUI just for this.
Update
With regards to the above, I have found https://groups.google.com/a/chromium.org/forum/m/#!topic/chromium-reviews/7mE61hDcFdA. Does this mean I could install Chrome on the netbook (even though I don't have a GUI) and port forward via CLI?
An APP might do the job here. If you know some java you might be able to pull it off. Basicly you tunnel a connection through adb, then use an app as proxy and a small program on the computer. There might be an easier way though

How to access LAMP localhost in android device for testing?

I am developing a Wordpress site in Linux using LAMP environment. I want to test the look and feel of the site in a mobile device. I have an android device.
Is it possible to test my Linux localhost site in an android device using wifi or USB? If yes, how?
Using - Ubuntu 12.04 - XAMPP Linux 1.8.0 - Android 4.0
Note: Before you dismiss this question as possible duplicate, I checked the stackoverflow questions but nothing helped.
Open for editing!
If both your device and your LAMP setup are on the same network, no problem. Just let the URL (on Android) be the IP- adress of your Site (for example http://192.168.0.5/yourwordpresssite)
You can also use an android emulator. The emulator has access to the loopback address via 10.0.2.2.
see: http://developer.android.com/tools/devices/emulator.html#emulatornetworking

Categories

Resources