Android emulator has no internet connection on linux OS - linux

Android emulator has no internet connection on linux OS.
using Android Studio
using Linux Operating System
Error is DNS_PROBE_FINISHED_BAD_CONFIG.
Changing dns server of local LAN/WLAN has no effect.

You can use the comand line tool emulator to add dns-server option:
~/Android/Sdk/emulator/emulator -netdelay none -netspeed full -dns-server 8.8.8.8 -avd YourDeviceName
To list your created devices you can use:
~/Android/Sdk/emulator/emulator -list-avds
See also:
https://developer.android.com/studio/run/emulator-commandline
https://developer.android.com/studio/run/emulator-networking#dns

Related

Connect to Android emulator from android studio dev env. in a Virtualbox vm

I'm trying to setup my Android/ iOS development environment. My setup includes the following:
A MacOS VirtualBox VM with Android studio and Xcode. The VM is running on a Windows desktop. The network for the VM is currently set up as bridge adaptor.
A Windows laptop with Android SDK and emulator.
All of the above machines are on the same LAN and I can ping one machine from another and vice-versa.
VM with Android Studio - 192.168.1.84
Laptop with emulator - 192.168.1.75
Emulator is running on the laptop on default port - 5554
Emulator IP address in the settings is showing as - 192.168.232.2
After reading the emulator networking guide, I tried setup the following redirection
redir add tcp:5000:5555
Subsequently, I tried connecting to the emulator from the MacOS VM by running the following command:
adb connect 192.168.1.75:5000
The above command resulted in:
failed to connect: '192.168.1.75:5000' - Operation timed out error
Could you please advise what I'm missing here. I need to set this up as I'm unable to run the Android emulator on the MacOS VM due to other constraints.
Any pointers would be appreciated.
Thank you in advance!
Update:
Further to above, I tried to use the following command on the laptop running the emulator to do the redirection:
netsh interface portproxy add v4tov4 listenport=5000 connectport=5555 connectaddress=192.168.232.2
Interestingly, now when I try to run the following adb command from VM containing Android studio, I get the following message -
adb connect 192.168.1.75:5000
already connected to 192.168.1.75:5000
However, the emulator (on windows laptop) name does not show up as a device in Android studio (on MacOS VM) and I cannot run my sample application.
Am I missing anything basic here?
One possible solution that does not requires any port redirection is the following:
On your laptop
Start the emulator
Use adb -a nodaemon server that restarts the adb listening on all the network interfaces
On your VM
Connect to the remote emulator instance by using this command adb -H 192.168.1.75 -P 5037 shell (or instead of shell any other commands)
Tested on Mac laptop and Linux VM.

How to configure KVM for Android Studio on Ubuntu?

No matter how I configure my system, Android Studio shows the "We have detected that your system can run the android emulator in an accelerated performance mode. Linuxed-based systems support virtual machine acceleration through the KVM. Search for install instructions for your particular Linux configuration hat KVM is enabled for faster Android emulator performance."
egrep -c '(vmx|svm)' /proc/cpuinfo gives 8
kvm-ok gives INFO: /dev/kvm exists
KVM acceleration can be used
grep kvm /etc/group gives kvm:x:108:currentLoggedInUser
How should I configure KVM correct on Ubuntu 19.10? And how could I tell if Android Studio is running the VM using KVM?
Thanks.
i had same issue, but the other way around. To make it work, first make sure you've enabled virtualization in the BIOS and added your username in libvirt.
Click cancel on the screen that shows Android KVM
Android Studio will offer you to two options. Choose the one "don't start the setup wizard" (not the recommended one), so it will take you to the welcome screen.
Start a new project as usual and Android Studio will say couldn't find the SDK.
Choose the libraries and emulators to download and the rest is the same as usual.

App crashing in Android Studio when I run the debugger

I have a Samsung Galaxy S8 and whenever I try to debug an app in Android Studio the app crashes and disconnects the phone from the PC.
I don't know if it's the drivers for the phone that I need to re-install or if there is a bug in the operating system or maybe something else.
I'm running Android Studio 3.1 under Linux Mint 18.3 Sylvia edition, and I'm running KDE.
Yes, there is a driver for Linux. You can get it from here:
https://dl.google.com/android/repository/platform-tools-latest-linux.zip
try following these steps to set it up correctly (I have it from https://www.xda-developers.com/install-adb-windows-macos-linux/)
Extract the ZIP to an easily-accessible location (like the Desktop for example).
Open a Terminal window.
Enter the following command: cd /path/to/extracted/folder/
This will change the directory to where you extracted the ADB files.
So for example:cd /Users/Doug/Desktop/platform-tools/
Connect your device to your Linux machine with your USB cable. Change the connection mode to “file transfer (MTP)” mode. This is not always necessary for every device, but it’s recommended so you don’t run into any issues.
Once the Terminal is in the same folder your ADB tools are in, you can execute the following command to launch the ADB daemon: adb devices
Back on your smartphone or tablet device, you’ll see a prompt asking you to allow USB debugging. Go ahead and grant it.install adb
Finally, re-enter the command from step #7. If everything was successful, you should now see your device’s serial number in the Terminal window output.

Linux Android ADB and AVD emulator connections

Right now, I have my Android SDK and ADB set it up on my Linux system. I have created an emulator under Android AVD Manager and it runs. The problem is that I am trying to connect to an emulator using ADB shell but every time when I do
adb devices
there is nothing being listed under the command. But when I physically connect an Android device into a computer, adb is able to recognize the physical device.
I have tried
adb kill-server
and
adb start-server
I have also ran everything under ROOT privileges and can't happen to narrow down what is the problem.
If you haven't already, please enable "USB Debugging" in the the emulated Android instance. If you already have, what is the output of lsusb? Are the ports open? Scan 5037 and 5500-5600 on the emulators IP address (assuming you are using a UNIX-based OS and have networking enabled in the emulator).
(see also: https://developer.android.com/tools/help/adb.html)

Building AOSP and launching the emulator

I am trying to launch the emulator after building the Android source.
Right now, the setup is like, I am running a windows machine connecting through putty to my linux machine. I have downloaded my source in the linux machine and I have successfully built it.
When I am running the emulator using the command in
https://stackoverflow.com/a/9023141/539472
the emulator is launching but only the android image is coming. From there on the emulator is not completely booting. Its not going to launcher.
The logs are
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
Failed to create Context 0x3005
There are many posts with this error, they say that check if the graphics driver is installed. I have checked it and its installed.
What might be the problem ?
Putty is just terminal console, it has no graphics/windows it cant possibly display emulator. Emulator is application like Browser or GEdit. If you login to you linux machine directly using Ubuntu then it can show emulator application.

Resources