Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Resolve adb version mismatch and PATH issues #153

Closed
brentvatne opened this issue May 9, 2017 · 49 comments
Closed

Resolve adb version mismatch and PATH issues #153

brentvatne opened this issue May 9, 2017 · 49 comments
Assignees
Labels
transferred Issue transferred from expo/expo repo

Comments

@brentvatne
Copy link
Member

Moved from https://github.com/expo/xde/issues/88

@gmaggess
Copy link

I'm facing the same issue. Any updates on this matter?

@ghost
Copy link

ghost commented May 16, 2017

Same issue

@ghost
Copy link

ghost commented May 16, 2017

Actually, I just clicked restart project on the XDE (without holding down shift) and restarted the emulator in Genymotion and now it works...

@mrbrackins
Copy link

Same issue

@amvd
Copy link

amvd commented May 22, 2017

Same issue. Restarting project + emulator did nothing for me.

@gmaggess
Copy link

I was able to make it work by setting up Android Studio correctly.

@vstlouis
Copy link

vstlouis commented Jun 9, 2017

Same issue

@brentvatne
Copy link
Member Author

For anyone reading this, please try this guide: https://docs.expo.io/versions/v17.0.0/guides/genymotion.html

If it doesn't work for you, please post the error message and any other information you think may be relevant. Thank you! :) :)

@vstlouis
Copy link

vstlouis commented Jun 10, 2017

I followed the instructions, previously I did not have the PATH set in my state file, but now it is there after running:

exp path

But I am still getting the error:

ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon`

@brentvatne
Copy link
Member Author

which of the options did you use from that guide @vstlouis? did you try both?

@vstlouis
Copy link

vstlouis commented Jun 13, 2017

@brentvatne I tried both. But what ended up working was

  1. running the exp path command to get PATH in my state file.
  2. Removing the android SDK installed by android studio from my path
  3. installing the android SDK from brew brew cask install android-sdk
  4. point genymotion to the newly installed SDK

I probably installed the SDK wrong or installing via android studio doesn't play well with Genymotion.

@brentvatne
Copy link
Member Author

if you're coming to this issue because you're having the same problem, please follow the instructions at https://docs.expo.io/versions/latest/guides/genymotion.html and then if that doesn't work, try the instructions that @vstlouis provided above. if the problem persists, please explain that you tried all of these things and give us as much information as possible about your environment

@merges
Copy link

merges commented Jun 14, 2017

I'm also having this issue. I followed the instructions in the docs and got this error:

couldn't start project on Android: could not install *smartsocket* listener: Address already in use
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon

I then installed Android SDK by downloading it from Google's website and using the Mac OS X desktop installer. I then pointed Genymotion to that SDK. The same error occurs.

I was unable to follow @vstlouis 's approach; the brew cask install android-sdk failed for me with a java exception (apparently my j2se runtime is the wrong version for some process in the android-sdk install script).

Genymotion works otherwise (the simulator starts up fine); i have a fake Nexus 5. Just no Expo on it ;)

@thewilliamchan
Copy link

I am having this issue as well on my macbook

@brentvatne
Copy link
Member Author

hmm.. @merges maybe we can do a screenshare sometime?

@valentinewallace
Copy link

valentinewallace commented Jun 20, 2017

I am getting the same problem as vstlouis. Running Ubuntu 16.04. I have a fake Nexus 5X, and Genymotion seems to work otherwise.

Edit: i was wrong, vstlouis's solution worked for me.

@rogerhu
Copy link

rogerhu commented Jun 20, 2017

Seems like expo adds adb symlink to /usr/local/bin on OSX. I fixed it by pointing to my Android SDK adb:

sudo ln -sf ~/Library/Android/sdk/platform-tools/adb /usr/local/bin

@bayyar
Copy link

bayyar commented Jun 22, 2017

vstlouis's solution worked for me as well.

@mitel
Copy link

mitel commented Jun 23, 2017

I think Option 1 from the docs (https://docs.expo.io/versions/v18.0.0/guides/genymotion.html) does not work for anyone as far as I could read on different threads. A more complete Option 2:

  1. Install the android-sdk (via brew or Studio)
  2. make sure that which adb returns that particular sdk's path to adb. If it's installed via Android Studio on Mac, the path would be something like /Users/alice/Library/Android/sdk/platform-tools/adb. Brew installs it somewhere in /usr/local/share/android-sdk
  3. point genymotion to the newly installed SDK
  4. add a genymotion virtual device and change the network to bridge
  5. start the virtual device, run a adb devices and see if the virtual device is running. That is different from the iOS experience where expo will open the simulator for you.
  6. click open on Android

@akfreas
Copy link

akfreas commented Jul 2, 2017

I was able to fix this by following @vstlouis' solution, but only after symlinking adb in the /Applications/Genymotion.app/Contents/MacOS/tools directory to the /usr/local/bin/adb link provided by brew. Seems kind of like the Genymotion ADB tool setting didn't take.

@danielkcz
Copy link

Hey. Does anyone have an idea where are Genymotion tools located on Windows? I've searched my whole profile folder and nothing there. It's not in the install folder either.

I would like to avoid installing Android Studio, I don't like to mess up my system more than necessary.

@Daky
Copy link

Daky commented Jul 10, 2017

@mitel 's solution work for me !! (I'm using mac pro)
thanks so much for saving my time

@alainpatrick
Copy link

@mitel's solution worked perfectly on my mac. Thank you so much!

@leanminmachine
Copy link

I followed @mitel 's steps and I still get this error message on Expo:

Couldn't start project on Android: could not install smartsocket listener: Address already in use
ADB server didn't ACK

  • failed to start daemon *
    error: cannot connect to daemon

I am probably doing something wrong here though because I installed adb via brew, but I am pointing my path to '/mins/Library/Android/sdk' (sdk installed via android studio). I got a message of 'Android SDK tools found successfully'. Pointing it to the path that I got via 'which adb' - /usr/local/bin/adb, led to 'Android SDK not found at this location'

Also is there any particular virtual device that we should be using or any virtual device would do?

@vlatkorun
Copy link

I solved the issue by setting the ANDROID_SDK_ROOT env variable in ~/.profile:
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk

I've installed the Android SDK tools with brew:
brew cask install android-sdk

@axrs
Copy link

axrs commented Jul 20, 2017

@mitel's solution and exporting ANDROID_SDK_ROOT as suggested by @vlatkorun (but using the AndroidStudio install) worked for me.

@ionflow
Copy link

ionflow commented Jul 30, 2017

I ran into this same error

ADB server didn't ACK
failed to start daemon *
error: cannot connect to daemon

Following these steps I was able to get it working with Genymotion and Android Studio (found in https://docs.expo.io/versions/v19.0.0/guides/genymotion.html):

  1. Installed Android Studio
  2. Installed Genymotion
  3. Pointed Genymotion settings custom SDK to: /Users/myusername/Library/Android/sdk
  4. Added path to adb tool directory in .bash_profile to: PATH="/Users/myusername/Library/Android/sdk/platform-tools:${PATH}"
  5. Restarted terminal for path to take effect
  6. Ran exp path in terminal to copy path to exp
  7. Ran adb in terminal to make sure it could find adb in platform-tools directory
  8. Restarted Genymotion
  9. Created and started virtual device in Genymotion
  10. Started Expo XDE and started project
  11. Ran Open on Android from XDE
  12. App started on virtual device created in Genymotion (step 9)

@paul-piro
Copy link

paul-piro commented Aug 2, 2017

One thing that i found on Mac, if you do not have adb in the path, Expo will copy adb in a ~/.expo folder and whenever you try to run the android app it will fail with the following error:

ADB server didn't ACK
failed to start daemon *
error: cannot connect to daemon

After deleting that folder and setting the path to Android SDK installed by Android Studio worked just fine. I'm using GenyMotion.

@anp
Copy link
Contributor

anp commented Aug 25, 2017

cc @fson if you have time to look at this

@this-miguel
Copy link

I have this issue in ubuntu when trying to start a project created with create-react-native-app, I already followed the guide https://docs.expo.io/versions/v18.0.0/guides/genymotion.html and tried option 1 and 2, niether worked for me:

Couldn't start project on Android: ADB server didn't ACK
* failed to start daemon *
error:

@this-miguel
Copy link

I solve the problem thanks to the analysis this guy https://stackoverflow.com/a/45456154/6115334, the problem was that I had a old adb version that was different from the version installed by android studio, it was in the usr/bin the somehow was first in the $PATH and was the one that was being executed, as the guy say may be different adb versions are the source of the problem. After I remove the problematic adb version everything works like a charm :)

@w10036w
Copy link

w10036w commented Oct 8, 2017

brew cask install android-sdk
Save my day. No need to uninstall android-sdk of android studio

@ankit7878
Copy link

ankit7878 commented Oct 11, 2017

Don't know exactly but i tried many thing.
i think below mentioned things will be useful (some how i solved this error coming while running android from expo):
Error:
error: could not install smartsocket listener: Address already in use
ADB server didn't ACK

  • failed to start daemon *
    error: cannot connect to daemon
    I solve some how.i hope below instruction will help:
    Solution:

Make sure Following things are set:

  1. Set SDK location :
    Genymotion->Settings->ADB-> <LOCATION_OF_ANDROID_SDK> (exmple: /Users/nc2-27/Library/Android/sdk)

  2. Go to your project directory and run following commands:
    -> npm install -g exp
    -> adb kill-server
    -> sudo xcode-select --reset
    -> exp android ( this command might tries to install expo latest version, etc)

Below things are not mandatory to follow ..this is just for reference:
-https://docs.expo.io/versions/latest/guides/genymotion.html
-Screenshot:
screen shot 2017-10-11 at 11 47 18 am

--and then run android emulator from EXPO and BOOM!!
THIS WORKS FOR ME.

@anp anp changed the title Investigate issues that some users have when opening app in Genymotion Resolve adb version mismatch and PATH issues Oct 11, 2017
@anp anp assigned fson and unassigned jesseruder Oct 11, 2017
@Maher4Ever
Copy link

@ankit7878 Thank you for sharing! Your solution worked for me after struggling with this issue for quite a while! The only difference is that i didn't install the android SDK separatly but actually used the one included with Genymotion.

@diaojinggang
Copy link

diaojinggang commented Nov 7, 2017

I struggled several hours to make it work. I am using Android SDK adb on Android Studio, Expo and Genymotion now. I magically had some other adb in Expo folder, I replaced it with Android SDK adb to remove the last obstacle. Here is the detailed debugging process.

I tried to add export PATH=/Users/myuser/Library/Android/sdk/platform-tools:$PATH and export PATH=/Users/myuser/Library/Android/sdk/tools:$PATH and then source ~/.bash_profile in my project folder. This didn't work.

I typed which adb under the project folder, it showed usr/local/bin/adb. I went to usr/local/bin and found a shortcut for adb. That shortcut points to /Users/myuser/.expo/bin/adb . I was pretty sure this expo adb was the criminal all the time. When I ran adb devices. I have the virtual machine on, but it gave me nothing.

I went to /Users/myuser/Library/Android/sdk/platform-tools folder, there was an adb file! This platform-tools adb is apparently what I should use. To verify it, I ran /Users/myuser/Library/Android/sdk/platform-tools adb devices, it gave me the ip and port of my virtual android device.

So I made the conclusion, expo was using a bad adb. Adding platform-tool adb path didn't work probably because usr/local/bin is always in the $PATH. So I gave up on configuring adb path. Instead, I copy the platform-tools adb file to overwrite the expo adb. No terminal command, just use Finder to open /Users/myuser/Library/Android/sdk/platform-tools folder and
/Users/myuser/.expo/bin/, copy adb in platform-tools, paste and replace the adb in expo.

Now everything works. And I am pretty sure you can also modify the usr/local/bin/adb shortcut to point to your platform-tools adb to make things work.

@yevhenlv
Copy link

yevhenlv commented Nov 19, 2017

After setting ANDROID_HOME, PATH variables, app opened on emulator (system Ubuntu, sdk Android studio).

@Jun711
Copy link

Jun711 commented Nov 24, 2017

@diaojinggang
Or you can do a sym link?

Mine works with this way that you tried:
I tried to add export PATH=/Users/myuser/Library/Android/sdk/platform-tools:$PATH and export PATH=/Users/myuser/Library/Android/sdk/tools:$PATH and then source ~/.bash_profile in my project folder.

@mfullbrook
Copy link

mfullbrook commented Jan 19, 2018

I had the same problem but have not installed Genymotion and have not installed the SDK via homebrew. I'm just using the SDK installed by Android Studio and the standard emulator.

add the following export and paths to your shell config:

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools

Remove the symlink added by xde: rm /usr/local/bin/xde
Remove the binary in ~/.expo just to be sure: rm -rf ~/.expo/bin/adb

Restart your terminal. Then run:

exp path

(You will need exp installed yarn global add exp)

Finally restart XDE 😃

@zofskeez
Copy link

Thanks @diaojinggang for setting me in the right direction. I too had an adb file that was taking priority in /usr/bin. What I did was simply replace it with the adb file from ~/Android/Sdk/platform-tools and the error is gone.

@Brabec
Copy link

Brabec commented Mar 3, 2018

If you are using Android Studio instead of Genymotions, like me, I solved it with this cmd:

$sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin

Thanks for this guy
https://stackoverflow.com/questions/38512025/react-native-run-android-mismatch-version-adb-server-version#38706579

@kylev
Copy link

kylev commented Mar 14, 2018

tl;dr I think xdl should stop bundling adb binaries because version mismatches suck.

Part of the problem is that xdl silently falls back to an out of date, bundled binary of adb that is likely a mismatch to whatever version you're running under Genymotion (whether bundled, installed by brew, or packaged with Android Studio). While this is laudable, it is also a recipe for confusion.

Currently, adb will do a version check on the running daemon before executing any command. If the versions don't match, it will print a warning and then attempt to kill the running daemon and start itself in its place. Sadly, the xdl-bundled version (1.0.32) prints an "out of date" message to STDOUT. This was changed to indicate a version mismatch and then later switched to STDERR. Since xdl only returns STDERR when something goes awry, none of us will see this message. If I simulate what xdl does while trying to connect to a running Genymotions emulator in my shell, I see the error:

[~/OSS/xdl]$   ./binaries/osx/adb/adb reverse tcp:5037 tcp:5037
adb server is out of date.  killing...
error: could not install *smartsocket* listener: Address already in use
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon

The "adb server is out of date. killing..." is on STDOUT and disappears when run by xdl. This will happen for anyone with a poorly configured PATH and modern SDK (which currently ships with adb 1.0.39).

In my testing, Genymotion will almost instantly restart the adb daemon when it exits. This is the race I'm seeing:

  1. The xdl-spawned adb command will kill the Genymotion-spawned daemon.
  2. Genymotion will restart the daemon.
  3. The xdl-spawned adb will attempt to spawn its own daemon, but fail to bind to port 5037.

Depending on time slicing, 2 and 3 may run out of order. Usually you get the google-able message that brings us here, but sometimes you'll get an out of date adb that makes Genymotion unhappy.

IMHO, xdl shouldn't package adb binaries since any revisions to the installed Android SDK will break xdl and its dependents. Instead, I'd suggest throwing an error when ANDROID_HOME isn't set and/or adb isn't found in PATH.

In the meantime, developers should make sure that the adb binary in your PATH is the one that matches your Android SDK. If you installed Android Studio from a package but didn't set up your shell, this is likely the case. It's not enough to have both Studio any Genymotion pointing to the same SDK: your shell (or however you run XDE or yarn start) must have the tools and platform-tools directories in the search path. Copying files around is unnecessary, and likely to break the next time you install a new SDK or upgrade Android Studio.

@drewbietron
Copy link

Tried about all of these -- make sure you restart XDE for the path changes to take effect

@IvesDotMe
Copy link

IvesDotMe commented Apr 6, 2018

This is how I solved in Windows 10

https://stackoverflow.com/a/49686208/145122

@sunilkumarc
Copy link

@denisSF
Copy link

denisSF commented Jul 23, 2018

In my case proble was that Genymotion was using it's own sdk.
Problem solved onse I've specified my local sdk path.

@attentive
Copy link

After installing Android Studio and GenyMotion under $HOME, I found a ~/Android directory had been created for the Android SDK.

  • I opened GenyMotion and changed the SDK path to ~/Android/Sdk in Settings
  • I executed sudo ln -sf ~/Android/Sdk/platform-tools/adb /usr/local/bin

and then the Expo startup began working. I think the socketserver error message must be misleading, as this seems to just be a case of Expo not being able to find the right instance of ADB?

@peruviangopher
Copy link

Thanks @vstlouis your solution works for me: ON LINUX UBUNT 16:

1.-) Removing the android SDK installed by android studio from my path
2.-) sudo apt-get install android-sdk
3.-) point genymotion to the newly installed SDK in my case "/usr/lib/android-sdk"

@SnehalAgrawal
Copy link

I was working on the Linux machine and faced the same issue and after some time found the solution

The main reason for this problem is the mismatch of your adb version.
You can see the problem using

Open the terminal and run

adb version
adbmismatch3

Now jump into the SDK >> platform-tools and run 

cd ~/Android/Sdk/platform-tools
adb version
adbmismatch4

Simple solution is copy your platform adb to /usr/bin
sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin

adbmismatch5

If you are still facing the problem then please visit here
https://aboutreact.com/adb-server-version-mismatch/

@sjchmiela sjchmiela transferred this issue from expo/expo Nov 6, 2018
@sjchmiela sjchmiela added the transferred Issue transferred from expo/expo repo label Nov 6, 2018
@EvanBacon
Copy link
Contributor

Closing because this seems to be resolved, I've also just rebuilt the Emulator module to support multiple devices so it's fairly different now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
transferred Issue transferred from expo/expo repo
Projects
None yet
Development

No branches or pull requests