I have a Chromebook that I've set up in Developer Mode, with a crouton-installed version of Linux running alongside. Within the Linux crouton, I'm running a simple web server.
My question is whether it's possible to access that server using any Android apps that are also running on that Chromebook?
Android apps have been installable natively on ChromeOS for some time, but everything that I've read says that they run in some kind of sandbox. ChromeOS itself is pretty tight with its firewall rules as well.
Just to get a start, I'm trying to use the Android version of the Chrome browser to load up a page that's running on a web server in the Linux crouton. I've tried localhost,127.0.0.1, and the Chromebook's current IP address.
I followed the instructions at https://developer.android.com/topic/arc/index.html to enable Developer Mode on the Android side and also, I think, loosen up those firewall rules on the ChromeOS side.
Is there some secret sauce that I'm missing? Is this even possible at all?
I had the exact same question and found this:
https://developer.android.com/topic/arc/index.html#network
It seems that in essence there is no IP traffic allowed from local Chrome to the Android web servers..
Update (thanks jlb for the ping)
However, you can run ifconfig in crouton. And then you can access your content via that IP address. I wonder if Firefox takes that shortcut for you..
Leveraging #tomdemuyt's post, his citation source says that android apps will be assigned a private IP address, so you can access local IP traffic, just not with localhost or 127.0.0.1.
For example, from termux execute ifconfig and look for the local IP address. Then run your service, e.g. node from termux, or kWs, any Android app.... and point Chrome to http://<your-local-ip-address>:<your-service-port>
127.0.0.1 and localhost will work from other Android apps, just not Chrome.
The solutions by jlb and tomdemuyt are for accessing a android app from chromeos (i.e. an ftp server)
However, I needed the opposite way (accessing an node server running in the linux virtual environment from android chrome browser) and that was basically the question ChillyPenguin asked for.
I finally solved it:
Start your webserver and ensure that you can access it with localhost (in my case http://localhost:8080
Within the chromeos terminal run
hostname -I
100.115.92.203 (and an ip:v6:adress:...)
(or ip addr show which is more verbose)
Now I was able to access the web server from android chrome with http://100.115.92.203:8080
Related
I am able to test serviceworkers over http with localhost but I would like to testg on a mobile browser. Because it is a separate device I cannot use localhost so I use the name of the PC. So now I need to use https, which is causing SSL related errors in my service worker:
Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://xxx:5500/app/') with script ('https://xxx:5500/app/service_worker.js'): An SSL certificate error occurred when fetching the script.
I have properly configured liveServer to use self-signed certs and I've successfully enabled "edge://flags/#unsafely-treat-insecure-origin-as-secure" but it is not enough.
I'm also concerned about how to test PWA on the mobile device as I presume I cannot make use of the "unsafely" feature on mobile. I assume this is a common scenario but I am not finding any answers.
You can test your PWA on mobile via chrome developer tools:
the method called remote debugging (works only for android)
open developer tools in mobile - allow usb debugging
connect via usb to laptop or pc
go to chrome dev tools open remote devices
set port forwarding in remote device
run local host in mobile chrome browser.
for detailed info follow : https://developers.google.com/web/tools/chrome-devtools/remote-debugging
this provides localhost in a mobile devices so no need for https or ssl.
I think this is the best way to test your PWA, I have personally used it.
Another working solution than is to use ngrok which will create a live https-server for the project you want (and then you'll be able to access it on your mobile device)
A very simple solution is to install Termux on your Android phone, then use socat to port-forward from a local port to your development host:
socat tcp-l:8000,fork,reuseaddr tcp:192.168.1.170:8000
This will run in the background while the terminal is open. Then in Chrome you can connect over plain HTTP to http://127.0.0.1:8000 and you should get the "Add x to Home screen" notice.
Works great over the local network and no certs, apps or services needed.
I am developing an app for android (with react-native) which is running in android studio emulator. This app should connect to a server, but I am in the testing phase and I run the server in a localhost port. but the localhost of another machine (which is in the same network that I am)
let's say the (local) IP of the other machine is 172.17.240.223 and the port which the server is running on is 8080
when I type 172.17.240.223:8080 in my browser (laptop browser), I get the response and there is no problem. Even when I type this in my browser in the emulator I get the response, but this won't happen in app. why is that?
More generally, it's not possible to customize the URL and how the bundle gets loaded. This flexibility is useful to have.
check issue on github here
in this case ,you can use testflight for IOS testing and for android just create apk.
I know the question sounds a bit confusing but here we go.
I am using an Azure VM to develop a cross platform app (Xamarin) and the app needs to utilise a .net core web API.
I am using a Google Emulator that has access to the internet.
What I have tried -
I have tried google emulators default connection 10.0.2.2:"MY WEB API PORT"/swagger. The result I get is "Bad request - invalid hostname"
I have tried a lot more but with no avail.
Any help is much appreciated.
Ok, the problem was that when I ran the Web service on ISS Express from Visual Studio it wasn't running on my local IP address 127.0.0.1:[MY WEB API PORT].
I found this out thanks to #JasonYe-MSFT who told me about the command
netstat -ant
When I ran the command I found that the port that my web app was running on wasn't attached to my local IP instead it was formatted like so
[::]:64339
So in visual studio instead of running the web app using IIS Express, i changed it too the project itself and when i ran the command again, the port now had my local IP address connected to it.
Inside the android emulator, i can now load the web api using AVD default IP address '10.0.2.2'. So the full address is
10.0.2.2:"MY WEB API PORT"/swagger
I am having trouble debugging the Xamarin Sports Sample locally on my development machine, so I can debug both the mobile app and the services on the same machine.
I have got the solutions open in Visual Studio 2015. I created my Google API Credentials and updated the settings with that info. I set the Azure domain to my local IP address (also tried localhost and a fake domain name). I added the authorized javascript origins and redirect URI's into the Google interface with the various combinations of IP, localhost and fake domain name.
It looks like the redirect URI cannot be an IP address. I have tried putting the fake domain name into my hosts file. I can run the services solution and it displays in the browser properly. I can hit /login/google in the browser and it looks like it works.
When I run the mobile solution in the emulator and click the login button, I get errors. During my troubleshooting, I have seen various errors, like name not resolved and a few others. I suspected that I could modify the device emulators hosts file to include the fake domain name, but I am not able to get the file system to be read-write, even after trying adb remount. That command says it was successful, but the adb push tells me the file is read-only.
I am using a Nexus 6 API 23 virtual device, if that matters.
Has anyone managed to get this sample to debug both mobile and services locally? Any suggestions on how I can modify the hosts file to see if that works? Any other thoughts on getting this to all run locally?
I have not tried running the iOS project, yet. Will that run into the same challenges?
Your device/emulator probably doesnt´t have access to your server machine.
Check your server local host ip, and run this with PowerShell as administrator:
netsh http add urlacl url=http://192.168.X.X:XXXX/ user=everyone
Replace the ip:port with your host ip and the app port.
Then create a new <Binding> in your applicationhost.config pointing to the above ip:port.
More details (and possible duplicate) here:
How to call your own ASP.NET MVC project preaent on same machine from xamrin webview
I am trying to write a client server application, in which the client is a android device.
I am not confident on socket programming.
I have written a server side application and a client side that runs on my emulator.
Will the same application work between a real android device?
I have edited your question (once its reviewed it will show up). From what I understand, your question is generic. It works on my emulator, will it work on my device.
The answer is yes. The emulator connects to 10.0.2.2 which redirects to 127.0.0.1 on your host machine right ? This is how you would have got it working.
To get it working from a device you will need to do the following
Load your java server on your real ip address on your desktop
Ensure that your desktop is on the internet and the ip address visible to the internet (open)
Ensure that your android phone points to the public ip address of your desktop.
Now, I know your worry :) open ip address. So, you can use a ec2 (free amazon ubuntu instance), install java on it and run your server as java -jar . From eclipse you can export a jar file (runnable jar file) with lib in your jarfilename_lib path.
You can use spring For android via HTTP request.
Here is an example.
When you have static ip in server you should set that static ip in your actual device.If you are running your app on emulator you must set 10.0.0.2.