Related
First of all, this is my first post here and I'm a beginner so my apologies if this ends up being a stupid question or my format is wrong, but any help is appreciated.
Essentially my problem is in trying to set up Unity Remote 5 for debugging in Unity. However, I believe I've finally narrowed it down. The error I'm getting now seems clear:
CommandInvokationFailure: Unity Remote requirements check failed
C:/Program Files/Unity/Hub/Editors/2019.4.17f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK\platform-tools\adb.exe forward tcp:7201 tcp:7201
stderr[ error: device offline]
stdout[]
exit code: 1
I've looked into this error and came upon this: https://stackoverflow.com/a/39031464/14948855 which seems like it might be useful to me, however the issue is I don't know how to run the commands he suggested and stack overflow made it clear it didn't want me posting a question as a response to that question and I don't have enough prestige to comment.
I'm trying to run "sudo adb kill-server" from an ubuntu linux terminal on windows from the directory abd is in (C:\Program Files\Unity\Hub\Editors\2019.4.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools), but it won't run.
proof command not found
I've tried adding it to the path on my computer: I added the directory listed above to "Path" in my "Environment Variables".
My phone is plugged in, I've disabled and reenabled developer mode and usb debugging, and restarted Unity and my phone several times. Any help with running this command in ubuntu or cmd, or even the greater problem of Unity Remote 5 would be fabulous.
Thank you.
Edit: here's a better image showing my issue:
image showing how I've tried to add the folder to the path but it still can't be reached
Final Update:
All my problems have been solved, here's how I got unity remote 5 for android working for posterity:
step 1) Make sure phone is in developper mode (go to "about phone" in settings, tap build number 7 times).
step 2) Make sure "USB debugging" is turned on in developer options.
step 3) Make sure Unity is updated to the most recent supported version through Unity Hub (might not be required but I did this step).
step 3) Download android support module through Unity Hub.
note: if you downloaded current Unity version from the Unity website rather than through Unity Hub, it doesn't seem to let you add modules to it through Unity Hub.
step 4) The sdk path Unity specifies by default is wrong for some reason, so in preferences->external tools, disable the default path and paste in the right directory (should be something like: C:\Program Files\Unity\Hub\Editors\2019.4.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK) to be safe I did this for the JDK, NDK and Gradle too.
step 5) When you plug in phone, pull down your notifications, hit "tap to change USB options" and make sure phone is in "camera" mode or some variation. For me it was "Photo transfer".
Note: if you don't have the option to change USB options, try different usb ports/cables, if those don't work you might have debris in your charging port, clean it out with a dab of 91% or 99% rubbing alcohol and a tooth brush/tweezers (this will also make charger sit more snug in phone)
That might be enough to get it working for you, if not...
step 6) (Not sure if necessary) May need to update phone drivers in device manager on windows.
step 7) If Unity gives an adb error saying too many devices connected, it's possible you have a daemon running in the background which adb is picking up as an android emulator because it's using a port greater than 5555. It seems adb checks open ports above port 5555, and assumes anything it finds is an emulator. To check this, as indicated in my original question, and as stated here: https://stackoverflow.com/a/39031464/14948855, in cmd on windows use adb devices (if ur on linux may need to use sudo) to get a list of all devices being detected by adb. (Also use "adb kill-server" to reset it.) If there is an emulator being detected, it should include the port it's using in its name, in my case it was "emulator-5562" in port 5562, which was apparently actually NTKDaemon from Native Instuments, a random music production program I've only used once so far. I'd suggest googling the emulator port you find to try and narrow down the process taking that port. The only thing left to do is to kill the process running in the port. I found NTKDaemon in task manager and also disabled it activating on startup because that's just evil imo.
And that should be it. Hope that works for you if you're here for help.
(btw in terms of my original question, I was able to access adb.exe by changing the directory in cmd, but I still never found why adding the directory to the path didn't work, so if anyone has an answer to that I would be interested)
I know that similar questions have been asked before, but my problem is new only after installing Android Studio 2.3, the latest version in March 2017. I have several years experience developing Android applications, and I have never encountered this problem before. After upgrading to version 2.3 of Android Studio, my emulator is no longer able to access the internet. I even uninstalled/reinstalled Android Studio 2.3 from scratch and created a new emulator, and I am still getting the same error. This is not an app problem. I can't even access the internet from Chrome, and I wasn't having this problem last week. The message that I get says that the server DNS address could not be found -- DNS_PROBE_FINISHED_BAD_CONFIG. The only thing that has changed on my computer in the last week is the new version of Android plus possibly updates to Windows 10. And yes, my computer has access to the internet. Below is an image of my emulator when I try to use Chrome to search for "Google".
1st try "Cold booting" the emulator as suggested here.
If cold booting doesn't work, try changing the DNS address of your network to 8.8.8.8 (Google's DNS) or another of your preference:
MacOSX:
Open "System Preferences"
Click on "Network"
Select the network which your computer is connected and click on "Advanced"
Select "DNS", Select the "+" button, type "8.8.8.8" (Google's DNS) or if you prefer OpenDNS, "208.67.222.222"
Select "Ok" and "Apply"
Windows & Linux:
https://developers.google.com/speed/public-dns/docs/using
After that close the emulator and start it again.
After trying many of these solutions, I was going to just delete my current AVD and make it again, but when I clicked the down arrow on the AVD, I noticed "Cold Boot Now".
On a whim I tried that. Lo and behold my emulator has internet connectivity again!
Command-line approach
In case you start Emulator through command, pass -no-snapshot-load option, like:
%ANDROID_HOME%/emulator/emulator.exe -netdelay none -netspeed full -no-snapshot-load -avd Pixel_2_API_28
Or for MacOSX:
$ANDROID_HOME/emulator/emulator -netdelay none -netspeed full -no-snapshot-load -avd Pixel_2_API_28
Note that you may need to change -avd Pixel_2_API_28 part (with your own Virtual-Device name).
Also, most tools use ANDROID_HOME environment-variable name, hence define that (if not already), but nowadays ANDROID_ROOT is yet another naming-option.
Decision (edit)
Ok, for those saying why not just wipe data and restart.
Do you reformat your PC every time you restart it? Wiping data on the emulator is just like doing a factory reset to a phone or reformatting your hard drive on your PC and reinstalling your OS. It is unnecessary unless the data is totally corrupt.
When you shut off the emulator and restart it, it is like putting your PC in hibernate or sleep mode. Memory is not wiped, it is saved.
Doing a cold boot is the same as rebooting your phone or rebooting your PC. It resets memory and lets things reload. This allows the network emulation to start with clean memory and connect properly.
So, don't wipe your data. Just cold boot. If it still doesn't work, then wipe, but save that as a last resort.
I found a temporary solution on an old Stack Overflow thread at Upgraded to SDK 2.3 - now no emulators have connectivity. Note that this thread talks about Android SDK 2.3, not Android Studio 2.3. The problem seems to be that the emulator can't find the DNS my computer is currently using, and the temporary workaround is to start the emulator from the command line and specify the DNS server. Whatever problem occurred back then must have reappeared in the latest version of Android Studio.
The temporary solution outlined below fixes the problem with the emulator accessing the internet. However, it does not fix the problem that occurs when trying to run Android Device Monitor. Doing so will still make the emulator go offline as described above.
Note that there are two files named "emulator.exe" in the sdk -- one under sdk\tools and another under sdk\emulator. Either might work below, but I use the one under sdk\emulator.
The first step is to find where the SDK is located. Assuming a user name of "jdoe" and a default installation of Android Studio on Windows, the SDK is most likely in
C:\Users\jdoe\AppData\Local\Android\sdk
The second step is to determine the name of the AVD (emulator) that you want to run. The command
C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -list-avds
will show the names of your AVDs. On my computer, it shows only one, Nexus_5X_API_25.
To start the emulator from the command line with a specified DNS server, use something like the following:
C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -avd Nexus_5X_API_25 -dns-server 8.8.8.8
In this case, 8.8.8.8 is a Google public domain name server.
The above commands can be shortened if you create appropriate environment variables and edit your PATH environment variable, but I recommend caution when doing so.
[UPDATE 2022] for Mac Users
For NOT Apple Silicon users
System Preferences
Network
WiFi > Select Advanced
From Advanced Choose DNS tab
Add DNS Server 8.8.8.8
Emulator must be restarted after DNS Server has been added (Thanks to #kapusch)
For Apple Silicon users
as per #bourdier-jonathan
You can fix the Silicon issue here:
Emulator appearing offline on M1 Mac after the last update of arm64-v8a
By replacing the AVD system images you have downloaded with the r02 images. Because It appears r03, r04, and r05 all don't work on m1
Updating my WIFI adapter to resolve DNS on 8.8.8.8 solved the issue for me. It started to happen after an Apple update which messed up the DNS address.
Simply open the AVD Manager and wipe the data of that emulator works for me.
Open Android emulator and go to the Extended Controls. Then go to the setting => proxy(Tab), uncheck "Use Android studio HTTP proxy setting" and click "Apply".
macOS: long Story short.. make sure your DNS settings 8.8.8.8 is the first in line, wipe your data and do a cold boot.
Reminder: the Android Emulator internet connection does not work if you turn on a VPN system on you computer.
I experienced this same issue after upgrade. Upon opening the Chrome browser in the emulator, google.com could no longer be reached.
I found a post on SO that suggested the problem was with the emulator trying to use a disconnected network adapter. For me the problem was occurring when I was connected to a LAN. Disabling the wireless LAN adapter fixed the issue.
To disable the adapter:
Navigate to Network connections
Find the adapter
Right click and choose disable
I've resolved wiping data from AVD Manager
This happend to me when the emulator froze and I had to kill the process. The signal icon always showed the small "x" as in the screenshot and no internet connection was successful.
The only thing that helped was uninstalling and reinstalling the emulator (not the AVD images)
In Android Studio:
Tools-> Android -> SDK Manager
Uncheck "Android Emulator" and let it uninstall then check again and let it install again.
I am also facing the same problem, but I am trying to solve the problem using various posts. Today I discovered this problem. Your computer configuration is most likely the problemm, not Android Studio and the Android Emulator.
The problem is coming from your Network setup. Just set the Primary DNS Server to 8.8.8.8, which will solve the problem.
I got a simple and permanent solution for this issue in windows.
Go to network and internet option->
click on Etherenet or wifi(for which you are connected) option ->
Click on change adapter option ->
Right click on the network for which you have connected.
A dialog box will be opened and just click on Internet protocal version (TCP/IPv4) option.
Another dialog box will be opened and there just neglect the first set about the IP address (Keep as it is set) and click radio button of Use the following DNS server addresses: and enter as 8.8.8.8 in Preferred DNS server: and 8.8.4.4 in Alternate DNS server:
Now you can open your emulator whenever and you will get internet in the android emulators.
For me the problem was caused when I took my laptop home without restarting the emulator. From what I have read, when the emulator starts up it reads your PC's DNS settings and uses them. When I was on my home network, my work DNS settings were failing.
So yeah. Just restarting the emulator solved my problem.
This was a problem for me last time the emulator updated itself and back then disabling other network adapters fixed it. Now it's cropped up again but the only adapter that is enabled is a single wifi one so I have nothing to disable.
The issue only reappeared after I updated via a prompt the emulator tools to 26.1.1. I uninstalled and reinstalled the emulator via the SDK Tools update tab and thankfully the only option when installing again right now is to install 26.0.3 (which seems to be working okay).
Moral of the story is to be very wary of emulator updates.
I faced this problem after i kept my emulator ON while going from my home to a cafe. "Cold Boot Now" fixed the issue.
After 10 days of trouble, I just deleted everything from C:\Android\.android\ and deleted all created AVDs. Now internet seems to work fine.
closing the emulator and reopening worked for me
OS
WINDOWS 10
Just goto AVD manager and Cold Boot Now worked for me
I can make it work after turn off and turn on the wifi on android config
Please go through the below link.
https://developer.android.com/studio/run/emulator-networking
Emulator open, click More ..., and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.
Enter the hostname by following
Run > cmd > hostname
Finally, check the internet access inside the emulator by browsing in chrome or google.
Note: Often wipe data will clear the issue. Please follow all steps
I am on android studio 3.1 and it happened.
Solved it by restarting the adb server
$ adb kill-server
$ adb start-server
Hope it helps. Thank you
There was a problem for me too, by disabling the proxy in Android Studio settings, and run the emulator with "Cold Boot Now", the problem was resolved.
Solution for MacOS that does not use a custom DNS for your whole machine
Step 1
Locate the emulator executable Android Studio is using inside the Android SDK and rename it to emulator-original.
Mine is located /usr/local/share/android-sdk/emulator/emulator but it might vary based on individual setups.
Step 2
Add a new file called emulator in the place of the original file containing the following command (or using your DNS server of choice).
#!/bin/bash
$0-original "$#" -dns-server 8.8.8.8
Step 3
Make the new emulator file executable.
chmod +x emulator
Step 4
Restart the emulator using Android Studio.
if android browser can access internet
you can run emulator from terminal
by this command
go to SDK path then
$ /tools/emulator -avd
Nexus_5X_API_23 -netdelay none -netspeed full
it solve your internet problem...
I was having the same issue and i resolved with below steps:-
Go to emulator setting and then go to
setting->Proxy->Either configure it Manually or use Tick use Android Studio HTTP proxy simulator.
please vote, if this works for you
Try these steps once, they worked for me:
Disconnect your PC from the internet
Close the emulator while you are still disconnected
Again connect to the internet
Finally start your emulator again
Just recreating the emulator with another target API worked for me
Maybe you set a proxy for Android Studio and the proxy does not work. Try without proxy.
I managed to get Android-x86 running in VMware player, but if I need to go to the command line by pressing Alt+F1 I cannot go back to the GUI. How do I restart the GUI from the command line?
To start the GUI, I had to select VboxVGA instead of VMSVGA in the VirtualBox display settings of the virtual machine.
Note: This is a solution to make it work with VirtualBox in case it helps someone who finds this question. It is possible that the solution to make it work with VMware player is similar.
I also found this information here:
Mandatory: Unless guest additions are installed, change the default
VMSVGA to VBoxVGA.
To fix this, you have to open the Virtual Machine Settings for your Android virtual machine and then go to the Display settings on the Hardware tab. Make sure that 3D acceleration is ticked! Start your Android virtual machine and wait maybe up to 10 seconds on the command line. It will then boot to Android GUI.
Adding another optional solution, because even though the most voted solution (written by JAGJIT DHALIWAL) helped me, it didn't do the whole job.
When trying to install android x86 8.1 (oreo) the suggested answer didn't do the trick and the my android VM was stuck on GUI initialization, after viewing this video my problem was solved.
What I had to do is:
to start the vm in debug mode, or open the CLI before GUI init first.
remount mnt: mount -o remount,rw /mnt
edit /mnt/grub/menu.lst (vi /mnt/grub/menu.lst)
appending this code to the first option (the first line starthing with kernel) nomodeset xforcevesa
save the file (:wq or :x)
reboot and the VM boots like magic with GUI
To go back to GUI try use Alt+F7
So I've thrown the book at this problem and think I've isolated the cause.
I've downloaded and installed JDK 32 and 64 bit.
I've installed the Android SDK as needed.
I've modified android_winusb.inf inside of the google-usb-driver to include the Kindle Fire device IDs.
I tried downloading the kindle fire windows 7 driver from amazon (as described in the answer here), and using that.
I tried modifying that driver to include the fire device ID in the x86 section.
I've killed and restarted adb diligently, and restarted my comp several times to see if that would magically fix it. nothing.
The only thing I'm unsure about is the modification of adb_usb.ini. Unfortunately, my .android folder doesn't exist in my %USERPROFILE%, but instead exists in another location on my computer. That folder doesn't have adb_usb.ini either. So I copied the contents of .android to my %USERPROFILE%, and created adb_usb.ini in each, and added 0x1949 to that empty file.
This did not work. adb devices still turns up zilch.
I think adb is having trouble finding my adb_usb.ini, but really, I have no idea. And if that is the case, I don't know how to fix that. Help?
Just adding 0x1949 to the adb_usb.ini was enough for me.
Make sure that you have added the right product/vendor id in adb_usb.ini file.
I had the same exact problem only after adding 0x1949 I could see the device listed.
Either amazon is changing the id's or people are giving wrong id's in random forums. The first one is definitely not required.
After adding the product id's my adb_usb.ini looks like this and I don't think your .android location matters
0x0e79
0x006
0x1949
This was driving me crazy also. Did recommendations from other links and posts and did not work. After running adb command without options, I saw an option for usb. I executed the following:
adb kill-server
adb usb
you should see some output after this, I didn't save the results
adb devices
Now showed my device
Type out your adb_usb.ini
cd /users/username
type adb_usb.ini
Make sure it shows 0x1949... mine had a special character instead of the x. Edit the file and change it manually to an x.
your device driver is not working go to the following link and update
http://www.jayceooi.com/2011/12/13/how-to-install-kindle-fire-adb-usb-driver/
Also double check that Windows isn't being sneaky and actually saving your adb_usb.ini as adb_usb.ini.txt when you create the file from scratch!
In my case, Windows was using the default driver. I uninstalled the windows driver.
Installed the driver at \android-sdk\extras\amazon\kindle_fire_usb_driver. Ran the following:
adb kill-server
adb usb
You should see some output after this, I didn't save the results:
adb devices
Device finally showed up. Kindle then showed up in device manager. Was not showing up there before.
In the %android_sdk%\extras\amazon\kindle_fire_usb_driver folder you can find KindleDrivers.exe file. Just run it and Kindle drivers for Windows (Win7 in my case) will be installed.
That sounds like you've done all the right things. For me the adb_usb.ini file did the trick and it's in c:/users/dirk/.android/adb_usb.ini. Oddly, I also added the product id of 0x006 on another line, thought I don't think that matters (the 0x1949 is the vendor id).
Make sure the adb_usb.ini is in the same folder as your avd folder. You can try creating a new AVD and look around to see under which user the new one was created.
Hope this helps.
So I had the exact same problem as you and I also had a problem with it looking for java.exe in my c drive instead of my d. I fixed this issue the same way I fixed that. Use the "mklink" command line tool to create a symbolic link in the C drive to your .android folder on your other drive. My exact command was:
mklink /D .android D:\.android
I was in my C:\Users\<User Name>\ folder
After that I ran adb kill-server and adb devices again and it showed up!
Hope that helps.
Adding this worked for me
0x1949
0x006
The main issue here is simple: for some reason when you install the drivers, the version of adv_usb.ini in the user/.android does not contain the vendor ID
I've check and the file was plain.
All that I had to do was to copy the ini file from the driver folder into username/.android and do a adb kill-server, followed by adb usb and the device was recognized.
In general, running "android update adb" from the /Tools folder should be enough to update the correct adb_usb.ini file. The location of this file is relevant as adb will only look for one of them. I had a CRC error in sdkuilib.jar, and it would not copy. This caused "android update adb" to fail, so my adb_usb.ini file did not get updated.
Also, when I went to update by hand, I was logged on as joe user, but I elevated to admin user to perform the update. I modified the joe user copy of adb_usb.ini (c:\users\JoeUser.android\adb_usb.ini), but the adb program looked instead at the admin copy of adb_usb.ini (c:\users\Admin.android\adb_usb.ini). So, adb did not see the 0x1949 that I added by hand.
Once I replaced my copy of sdkuilib.jar (by redownloading, installing in a separated folder, and copying over the bad file), I was able to run "android update adb" and 0x01949 showed up in my admin adb_usb.ini. [To find this, I changed echo off to echo on at the top of both the android.bat and find_java.bat files.]
After that, I did an adb kill-server and adb usb. But I still got the "error: device not found" message. Only then did I notice that my Kindle Fire had timed out. I turned it back on, unlocked it, and at that point, the kill-server "adb usb" sequence produced "restarting in USB mode".
Once that output was produced, the adb devices showed my Kindle Fire.
I had this exact issue for the longest time - Michael's answer lead me to the answer that fixed this for me.
If you don't currently have a C:\Users\[Username]\.android folder, add one manually. Copy adb_usb.ini into this folder. Windows may give you some trouble if you try to create this folder in Windows Explorer (beginning the folder with a period, probably). I had to open cmd and type move android .android to accomplish this.
After doing this, adb devices immediately showed the device.
For future readers' reference:
Don't forget to turn on USB debugging on the device. (At least in my case, on OUYA, this is disabled by default.)
If you are using Windows and you have the Android SDK installed (if ANDROID_SDK_HOME environment variable is set) then adb will use %ANDROID_SDK_HOME%\.android\adb_usb.ini instead of %USERPROFILE%\.android\adb_usb.ini
Also this post has a command to populate your adb_usb.ini with Vendor IDs of all currently connected adb devices.
In my case, I had to install Kindle Fire drivers.
If you can't find it in your local disk, you can download from official Amazon page:
https://developer.amazon.com/public/resources/development-tools/ide-tools/tech-docs/05-setting-up-your-kindle-fire-tablet-for-testing
Direct link:
https://s3.amazonaws.com/android-sdk-manager/redist/kindle_fire_usb_driver.zip
m3 http://img245.imageshack.us/img245/461/65254534.jpg
Chrome using the windows' HOST file:
m1 http://img266.imageshack.us/img266/9380/59750633.jpg
Android emulator:
m2 http://img821.imageshack.us/img821/7363/19470766.jpg
edit
"On Windows, the emulator obtains the addresses by calling the GetNetworkParams() API. Note that this usually means that the emulator ignores the content of your "hosts" file (/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS on Windows)."
how can I use static IPs in the emulator?
I got this article, it explains how to edit the hosts file. I don't know if it works yet, bit it might help.
BROKEN (Feb 2015) - http://www.bradcurtis.com/2011/02/13/hosts-file-google-android-emulator/ (Leaving it in case it recovers)
If I'm not wrong, they moved the link here, I'm not sure if it's the same article, I haven't touched this since may 2012.
http://www.bradcurtis.com/hosts-files-and-the-google-android-emulator/ (Mirror Link https://web.archive.org/web/20180615121728/http://www.bradcurtis.com/hosts-files-and-the-google-android-emulator/)
EDIT: Adds a new link that works and talks about the ame issue (Not sure if it's the same article.
FWIW, it's not possible to change the phone's own /etc/hosts file within the emulator - it's on a read-only file system.
Personally, I'd run a local resolving server on your PC, point your Windows O/S at that, and then override the entries properly.
Unbound will do the job, and has a nice feature to allow you to insert "local data" into your DNS results.
It is possible to update the Android phone's own hosts file with:
adb remount
adb push hosts /etc/system/hosts (most tutorials suggest this file)
adb push hosts /system/etc/hosts (some VM systems seem to prefer this file instead!, for me this worked)
if any issues like i kept randomly getting a 'read-only file system' error 90
% of the time I tried running above, then try running 'adb root' before above (didnt work for me through), or start the Android VM manually with your android sdk's emulator.exe:
emulator.exe -avd Nexus_6_API_23 -partition-size 512
(some peeps recommended making partition size manually so can write to the VM easier?, eh seemed to work better but still got random read-only errors still).
An Android VM created with GenyMotion seemed much stabler and never get 'read only file system' issues with their VMs when i tried pushing the hosts file.
If the website you want to look at is hosted on your host machine, then you can point to it via a special IP android VMs recognize as the host machine via the hosts file:
10.0.2.2 test-drupal8.localhost
or if using Bridged Networking instead of NAT (pretend your windows host machine is 172.16.6.50 where your website is hosted and Android VM is 172.16.6.51), then can use windows ip directly:
172.16.6.50 test-drupal8.localhost
Note: make sure Windows Firewall/antivirus/firewalls are off if testing as they were blocking my urls until i turned them off.