How to mitigate local network problem with Expo - android

Expo is crashing when using an Android emulator on my Ubuntu machine. So what I want to do is upload the app to my real Android device using Expo. But when I do this using the local wifi network, I get:
Perhaps I should just physically tether my phone to my Ubuntu laptop instead of going through Wifi? What about bluetooth to upload the app to the phone from my Ubuntu machine?

In the tutorial there is an explanation of how to handle this: https://docs.expo.io/get-started/create-a-new-app/
Is the app not loading on your device?
First, make sure that you are on the same wifi network on your computer and your device.
If it still doesn't work, it may be due to the router configuration — this is common for public networks. You can work around this by choosing the "Tunnel" connection type in Expo Dev Tools, then scanning the QR code again.
🐢 Using the "Tunnel" connection type will make app reloads considerably slower than on "LAN" or "Local", so it's best to avoid tunnel when possible. You may want to install a simulator/emulator to speed up development if "Tunnel" is required for accessing your machine from another device on your network.
An aside -- I've opened an issue here to discuss adding an easy and fast way to connect to your device under these circumstances.

Related

Testing Network Throttling using chrome dev-tools for an android app does not work

Goal: Test android app on a physical device with various network connectivity issues (Offline, Slow 3G etc). Android Emulator is not an option for my use case.
Steps I have tried: (Remote Debugging)
Connect my phone to my computer and open the app on my phone.
In chrome "Remote devices" I select my phone and click on inspect for the app opened on my phone. Once the Developer Tools window opens I can play with my app from chrome.
In the network tab I can see the throttling options but when I try the offline option or any other option to slow down the network it does not seem to work.
The offline/slow 3G option works for a normal website but not when using remote devices. I wanted to see if anyone has tried this option before and if it worked for them and I would appreciate suggestions for better alternatives to test an android app with various network settings other than using chrome remote devices?
Other options I have come across are installing a proxy app on PC/Mac and configure networking throttling in the app and then create a wifi hotspot and connect my phone with it. This is possible but it would be tricky with the tools we use so I was looking for a more elegant solution.
The "remote devices" of chrome won't affect your native app. It will not even affect another opened tab other than the one you are "inspecting" and throttling. If you really need to throttle your device's network connection you should use a proxy. A good and easy to handle proxy is Charles web debugging. The free version will cover your needs if you are willing to reconnect every 30 mins. But for sure I recommend you purchase a license since this tool will be always helpful and developers also need to make a living ;)
Here is an example of setting up Charles as a proxy for an android device.
It's a little unclear from your question, but I'm assuming that you're using Remote Debugging to run a webpage on an Android device, and you want to profile the webpage from a laptop/desktop connected to the Android.
One workaround is to use https://www.webpagetest.org/easy. This actually runs your webpage on a real Motorola G device in Virginia with a Slow 3G connection. It gives you a detailed report on your loading performance, just like the DevTools Performance panel.
One of the DevTools team members said that Remote Debugging + Network Throttling should work, but neither of us has tried it recently.

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 run wifi peer to peer application in android emulator..?

I am trying to develop an wifi peer to peer application in android(4.+).
The problem here is how to test it.
I tried to run that application in android emulator. there was no option to configure wifi in the settings menu, i also tired to enable wifi using the dev tools application form the emulator but it didn't work, And through all my googling over 3 days and i found that Android emulator is not supported the Wifi.
So i opted for androidx86 4.0eeepc using virtual box and tired to add devices both wifi and bluetooth (my app uses both bluetooth and wifi) but only bluetooth device got added and it did not work. But my virtual box detected the wifi and bluetooth devices. I just couldnt get them work with the virtual machine.
I tried everything like manually adding the addresses using terminal emulator app in androidx86 and used netcfg through the android commandline but neither of them worked.
Please suggest and guide me on the correct path to run these kind of applications that use wifi and bluetooth in android.
Thanks in advance.
First, be sure you enabled WiFi Direct in the Android settings for the two virtualbox instances:
Settings --> Wireless & Networks --> More... --> Wi-Fi direct
It has been stated as working once that hurdle was overcome, and I'm sure many have experienced the same...just be sure to enable wifi direct
I would have tried exactly what you've already tried by naturally moving from the emulator to the androidx86 project. Although unreliable, I'd recommend looking at and finagling this, if you haven't yet seen it: Android: Simulate WiFi in the emulator? and How to disable/enable network, switch to Wifi in Android emulator? most likely wouldn't have full out success but may be enough to let you know that it works or would work.
As far as testing WiFi-Direct/WiFiP2P without you yourself having a device/s, I would recommend:
Trying out some of the fiddling as mentioned above. And read through tons of logs.
You could always crowd source it to friends, or release an apk on a forum for a small group of testers.
Of course, both of those options are not ideal, seamless, or fast. So, I'd definitely hope you get VirtualBox VMs of AndroidX86 4.0 running as it should once you check that setting and pair up the WiFi APs :-)
A near future solution:
This might be something to look into in near future.
Real devices are hosted by Samsung and screens are streamed to your PC.
http://developer.samsung.com/remoteTestLab.do
According to an email responded by samsung, which I sent to them earlier.
They only have 2 devices (Galaxy Nexus) running on Android v4.0 at the moment.
Unfortunately they are not physically close to each other. (One in Korea, One in Poland)
But they are planning to upgrade existing Galaxy S2 to v4.0.
Because recently Samsung have released v4.0 upgrade for S2.
Once they done that, there will be plenty of v4.0 phones.
And you can ask them which 2 phones are physically close so you can test Wifi Direct.
--------------------------- EDIT ---------------------------------
There are plenty of ICS devices there now, which you can test P2P.
Check with them which 2 are physically near to each other.
Per the docs:
Each instance of the emulator runs behind a virtual router/firewall
service that isolates it from your development machine's network
interfaces and settings and from the internet.
You have to use Network Redirection, as described in the Developer Docs. In essence, you forward specific ports using ADB. Therefore you cannot test certain things like broadcast messages.
I have tried doing what you are trying to do, and-- while I won't say it is impossible (anything is possible in computing with enough time, money, and persistence)-- I wasted a lot of time on it. You cannot treat the Android emulator as a normal network peer-to-peer device. As far as I have been able to find, it is a fork of QEMU, and that is just how the QEMU emulator is implemented.
QEMU itself does support TUN/TAP bridging, but I was never able to get it working with the Android emulator. If you want to go that route, you may want to investigate running Android in the QEMU emulator, rather than in the SDK's emulator (I see you are already trying a similar approach with VirtualBox).
Unfortunately the best way to test a peer-to-peer networking program in Android is with physical devices at this time-- unless your app can suffice with the port forwarding method.
See Also: Issue 26:Emulated Androids should be able to communicate via TCP, and Google
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.

Android USB debugging with PC internet connection

I'm having Samsung Galaxy S phone.
I want to debug my application, which needs internet connection.
can I debug my app with android device, sharing the PC internet connection through USB?
I can not use WiFi.
Please help me out. Thanks in advance
Getting the internet from your PC to your android device is called reverse tethering. It is tricky cause it s not a built in feature. Some solutions exist if your a linux user :
http://blog.mycila.com/2010/06/reverse-usb-tethering-with-android-22.html
Previous link is dead, found a copy there:
https://web.archive.org/web/20120320173806/http://blog.mycila.com/2010/06/reverse-usb-tethering-with-android-22.html
Don't know if it's still relevant the question is old considering Android lifetime.
If you are not, well I never find a way.
There are two current (2019) tools that do this job well:
gnirehtet
This project provides reverse tethering over adb for Android: it allows devices to use the internet connection of the computer they are plugged on. It does not require any root access (neither on the device nor on the computer). It works on GNU/Linux, Windows and Mac OS.
It's written in Rust and Java; you can choose the server component. It requires adb on the host, and at least Android 5.0. The device itself will then be managed by the program.
SimpleRT
Reverse Tethering utility for Android.
Allows you to share your computer's internet connection with your Android device via a USB cable
This one requires no adb and no rooting, but you have to build the Android APK file yourself or download a release version.

How to set up an ad hoc network by using the shell on a rooted Android device?

In the moment I am working with some ad hoc routing protocols (namely OLSR and B.A.T.M.A.N.) on rooted Android devices running Cyanogenmod. My tests are working pretty well. However, there is one thing which really is annoying: I can only connect to an existing ad hoc network, but not create one manually using only the phones. Right now I am using my laptop to set up an ad hoc network and to run a small DHCP server.
Do you know how to create an ad hoc network manually by using the shell on Android? I have found some methods how this should work, but none did work for me. I tried using ifconfig, iwconfig, netcfg and even wpa_cli (which seemed to be the best choice for this). But after any try the system fell back into "no wifi connected" state - even if the phone stayed in ad hoc mode for a couple of seconds while searching for an IP.
I will be so gladful if I can finally get around this problem because then I might actually use my laptop for Internet access (and therefore searching for online help during the tests) instead of using it to set up an ad hoc network. :-)
I'm not really clear on the technical details, but android-wifi-tether requires you to have a custom kernel with NETFILTER support, which I don't know if Cyanogenmod has. You might try using another open source project as an example: Barnacle Tether. It doesn't require a custom kernel.
I've started looking at the source for Barnacle for my own project. It's pretty easy to compile, but I've only just begun playing with it so I don't know the exact answer to your question.
Correct me if I'm wrong, but didn't the old cyanogen tethering app (android 1.6, before tethering was officially offered) create an ad-hoc network for the tether clients? (I ended up using it not to tether, but just to set up a network so I could ssh into the phone from a laptop while I was playing around with USB host drivers and so couldn't use ADB.)

Categories

Resources