Connect an AVD to WiFi instead of 3G [duplicate] - android

How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G.

Wifi is not available on the emulator if you are using below of API level 25.
When using an AVD with API level 25 or higher, the emulator provides a
simulated Wi-Fi access point ("AndroidWifi"), and Android
automatically connects to it.
More Information:
https://developer.android.com/studio/run/emulator.html#wifi

Apparently it does not and I didn't quite expect it would. HOWEVER Ivan brings up a good possibility that has escaped Android people.
What is the purpose of an emulator? to EMULATE, right? I don't see why for testing purposes -provided the tester understands the limitations- the emulator might not add a Wifi emulator.
It could for example emulate WiFi access by using the underlying internet connection of the host. Obviously testing WPA/WEP differencess would not make sense but at least it could toggle access via WiFi.
Or some sort of emulator plugin where there would be a base WiFi emulator that would emulate WiFi access via the underlying connection but then via configuration it could emulate WPA/WEP by providing a list of fake WiFi networks and their corresponding fake passwords that would be matched against a configurable list of credentials.
After all the idea is to do initial testing on the emulator and then move on to the actual device.

As of now, with Revision 26.1.3 of the android emulator, it is finally possible on the image v8 of the API 25.
If the emulator was created before you upgrade to the latest API 25 image, you need to wipe data or simply delete and recreate your image if you prefer.
Added support for Wi-Fi in some system images (currently only API
level 25). An access point called "AndroidWifi" is available and
Android automatically connects to it. Wi-Fi support can be disabled by
running the emulator with the command line parameter -feature -Wifi.
from https://developer.android.com/studio/releases/emulator.html#26-1-3

(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.

The emulator does not provide virtual hardware for Wi-Fi if you use API 24 or earlier. From the Android Developers website:
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
You can disable Wi-Fi in the emulator by running the emulator with the command-line parameter -feature -Wifi.
https://developer.android.com/studio/run/emulator.html#wi-fi
What's not supported
The Android Emulator doesn't include virtual
hardware for the following:
Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB
The watch emulator for Android Wear doesn't support the Overview (Recent
Apps) button, D-pad, and fingerprint sensor.
(read more at https://developer.android.com/studio/run/emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi

When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
Source : https://developer.android.com/studio/run/emulator.html#wi-fi

If your simulator is not connecting to wifi and your in a mac(I don't know how to add DNS in windows) just go to
Network -> advance -> DNS and add 8.8.8.8 and 8.8.4.4 the close the android simulator, open android studio, select the simulator and click on cold reboot then your simulator will be connected to wifi.

Related

How to connect a custom wifi network in the emulator?

Team, I set up an android emulator in my mac [Api level 28, os 9]
I can see by default it is connected to 'androidwifi'.
How do i connect the same emulator to my corporate wifi so that i can test my app inside that.
Your emulator will use your computer's hardware to emulate every relevant aspect of the hardware of a real device. Likewise, the "androidwifi" network is a simulation of the actual wifi network that your computer is connected to.
If you want to change the settings and test different speeds/latency/etc you can do it via the emulator settings. Some of them (eg. netspeed) can be further configured manually with commands. Here's a list from the developer's guide.

Access Modem - Android Device (Nexus 5)

Device : Google Nexus 5 (Un-rooted)
Host Machine : Window 7
I want to Access Android Device as a Modem (using COM or Modem Port) and eventually pass AT Commands using HyperTerminal/Teraterm.
So after connecting the device to a Windows Box, The Device gets detected under Device Manager, but doesn't show any COM Port (other than the default COM0).
On right click and update driver, It shows it cannot find drivers.
I have tried the following options, but no luck with any.
Tried this on a rooted Nexus 5, but doesn't expose which /dev/smdX to use. Tried all combinations, didn't work.
Tried the Google USB Drivers from the Google Android's Website. No changes.
From here. I Installed drivers from LG Electronics, No changes in COM Port.
Universal Naked Driver helped me get to ADB Shell interface, but
thats not what I want.
In all of the Above procedure USB Debugging was enabled (Just saying).
I also heard the phone has to put into Modem mode to fire AT Commands.
If so, How do I do that ?
Or Is this a device driver Issue ?
Conclusion:
I want to access the Modem of the Android Device and fire AT Commands to it.
Could you please tell what am I missing ?
Any help on this would be really appreciated.
It's difficult to give an exact answer to this question, because it depends on how the manufacturer has implemented the device drivers. Unfortunately, there is a lot of information that isn't in the public domain.
It is possible, that the manufacturer has implemented some code to convert the device to a modem. Doing this yourself is device-specific, and proprietary. You might be able to get hold of a converter, for example bundled with the manufacturer's dashboard application for the PC, if such a thing exists.
Some devices don't expose the modem port at all. They may be visible as a network adapter, or as an always-connected LAN connection. If the device is visible as a network adapter, then you can access it via Windows Mobile Broadband API, or via MBIM for some newer devices.
To check if the device is visible as a network adapter, and get information about it, open a cmd box and type
netsh mbn show interfaces
Windows Mobile Broadband API doesn't give as many details as a good AT command set, but performs basically the same functions. MBIM is an industry standard interface with similar functionality, available on the Windows 8+ desktop via the Mobile Broadband DeviceServices API, for devices that support it.
If the device shows as an always-on LAN connection, there is probably a proprietary, high level interface for mobile functionality.
Driver behaviour can differ for different operating systems. If you have the chance to try the device on Windows Vista, 7 and 8, you may see different behaviour.

Using Bluetooth in Android Emulator

If I wanted to implement an app for 2 Android devices so I can connect from one to the other via bluetooth, how can I do that via emulator?
HINT: I don't have an Android phone for simulating.
Thanks.
There are few limitations for the Android Emulator. The functional limitations include:
No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however.
No support for USB connections
No support for device-attached headphones
No support for determining network connected state
No support for determining battery charge level and AC charging state
No support for determining SD card insert/eject
No support for Bluetooth
Source Link
I've found the way to debug bt-enabled application on virtual android with real devices. That is not ADK emulator, and it has some flaws, but it definitely works.
Host computer works under Windows 7 64-bit with standard BT stack. Step by step:
Install VMWare Player. It's free for non-commercial usage
Create virtual machine. Set "Other linux 2.6" guest OS type.
Choose reasonable amount of RAM. Remove SCSI disk and printer. Add IDE disk at least 1 GB, keep USB controller, ensure if bluetooth devices are shared with host computer.
Download android installation from android-x86.org. I recommend Android 4.0 RC2 for EEE PC
Point VM's CD to the ISO file.
Start the VM and install android. Unfortunately, it's impossible to add google account there for now.
Switch to android console(Alt-F1 inside virtual machine) and ask for IP address(use netcfg command, look at eth0 network interface), then switch back to GUI(Alt-F7)
On host machine, run adb.exe connect your-vm-ip
Enjoy!
Here is an illustrated tutorial in Russian
You can't use an emulator to test bluetooth apps. The BluetoothAdapter will remain null in emulator. You would need a bluetooth device.
Reference link of accepted no longer exists and I can't seem to find any other pages the mentioned the exact same details. However, it is mentioned in this docs:
What's not supported
The Android Emulator supports most features of a device, but doesn't include virtual hardware for:
WiFi
Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB
The watch emulator for Android Wear doesn't support the Overview (Recent Apps) button, D-pad, and fingerprint sensor.
While most end users of phones and tablets tend to use earlier API levels, Android Wear and Android TV users tend to use the latest releases. Using recent releases can give you a better experience using the emulator.
In addition to elmot's method (which I have seen on various places on the net and has been reported to work), you may also consider this utility which seems to do exactly what you would need:
https://github.com/cheng81/Android-Bluetooth-Simulator

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.

Enabling WiFi on Android Emulator

How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G.
Wifi is not available on the emulator if you are using below of API level 25.
When using an AVD with API level 25 or higher, the emulator provides a
simulated Wi-Fi access point ("AndroidWifi"), and Android
automatically connects to it.
More Information:
https://developer.android.com/studio/run/emulator.html#wifi
Apparently it does not and I didn't quite expect it would. HOWEVER Ivan brings up a good possibility that has escaped Android people.
What is the purpose of an emulator? to EMULATE, right? I don't see why for testing purposes -provided the tester understands the limitations- the emulator might not add a Wifi emulator.
It could for example emulate WiFi access by using the underlying internet connection of the host. Obviously testing WPA/WEP differencess would not make sense but at least it could toggle access via WiFi.
Or some sort of emulator plugin where there would be a base WiFi emulator that would emulate WiFi access via the underlying connection but then via configuration it could emulate WPA/WEP by providing a list of fake WiFi networks and their corresponding fake passwords that would be matched against a configurable list of credentials.
After all the idea is to do initial testing on the emulator and then move on to the actual device.
As of now, with Revision 26.1.3 of the android emulator, it is finally possible on the image v8 of the API 25.
If the emulator was created before you upgrade to the latest API 25 image, you need to wipe data or simply delete and recreate your image if you prefer.
Added support for Wi-Fi in some system images (currently only API
level 25). An access point called "AndroidWifi" is available and
Android automatically connects to it. Wi-Fi support can be disabled by
running the emulator with the command line parameter -feature -Wifi.
from https://developer.android.com/studio/releases/emulator.html#26-1-3
(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.
The emulator does not provide virtual hardware for Wi-Fi if you use API 24 or earlier. From the Android Developers website:
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
You can disable Wi-Fi in the emulator by running the emulator with the command-line parameter -feature -Wifi.
https://developer.android.com/studio/run/emulator.html#wi-fi
What's not supported
The Android Emulator doesn't include virtual
hardware for the following:
Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB
The watch emulator for Android Wear doesn't support the Overview (Recent
Apps) button, D-pad, and fingerprint sensor.
(read more at https://developer.android.com/studio/run/emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
Source : https://developer.android.com/studio/run/emulator.html#wi-fi
If your simulator is not connecting to wifi and your in a mac(I don't know how to add DNS in windows) just go to
Network -> advance -> DNS and add 8.8.8.8 and 8.8.4.4 the close the android simulator, open android studio, select the simulator and click on cold reboot then your simulator will be connected to wifi.

Categories

Resources