'scrcpy not working while VISUAL STUDIO CODE is working

I'm using Ubuntu 20.10 and I have installed scrcpy to mirror my phone screen while creating flutter applications, but when I just open Vs code, scrcpy closes with this error :: adb server version (41) doesn't match this client (39); killing...



Solution 1:[1]

Same things was happened for me in Android Studio during Flutter App development. So my solution for Android Studio running on Ubuntu 20.04 is given below:

Solution:

Please do the following steps:

  1. If you have "Android SDK Platform tools" installed then please uninstall it from "Android Studio --> Tools --> SDK Manager --> SDK Tools(Tab)"

  2. Now, please mark "Android SDK Platform tools" from the list that is found under "SDK Tools(Tab)". The path of "SDK Tools(Tab)" is "Android Studio --> Tools --> SDK Manager --> SDK Tools(Tab)". After that, press "OK" button to install.

  3. Then, from terminal, please type following command to check the presence of "adb" file under "Android --> Sdk --> platform-tools"

"cd /home//Android/Sdk/platform-tools/ && ls"

  1. After that, please remove current adb file from "/usr/bin" and then copy adb file to "/usr/bin" from "/home//Android/Sdk/platform-tools/" using following commands:

"sudo rm /usr/bin/adb && sudo cp /home//Android/Sdk/platform-tools/adb /usr/bin/"

  1. Finally, please restart the adb server using following commands:

"kill adb-server && start adb-server"

  1. Now, please check either everything is ok or not using following commands:

"adb version && adb devices"

Solution 2:[2]

this error is Conflicts between adb versions https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#conflicts-between-adb-versions

Solution is set ADB env is path to Android Sdk platform-tools adb

/home//Android/Sdk/platform-tools/adb

in Linux, you can

export ADB=/path/to/your/adb

in Win,

set ADB=/path/to/your/adb

Solution 3:[3]

Since you're on Linux, you can take the adb path:

1. First get your adb path.

example: /home/Your-User/Android/Sdk/platform-tools/adb

2. Second open your terminal or terminal emulator and type: export ADB=[adb path]/adb

example: export ADB=/home/Your-User/Android/Sdk/platform-tools/adb

3. You must always run this command when restarting your terminal.

Solution 4:[4]

Ok I have recently found solution for this issue. Since it is impossible 2 adb work in the same time, you should use one of them. To implement this:

  1. open vscode
  2. in vscode terminal $export ADB=/home/your_username/Android/Sdk/platform-tools/adb scrcpy run this command
  3. Then run $scrcpy command as well. I hope it works. However you should do above steps every time you open vscode!

Solution 5:[5]

If you're using Ubuntu try this, open up your terminal: ctrl + alt + t

First check if you have adb in your platform-tools directory.

Enter this commands to check first:

cd /home/change-this-to-your-username/Android/Sdk/platform-tools/

ls

You should see adb listed in your terminal.

If yes, do not close your terminal yet, and open up another terminal: ctrl + alt + t

Enter command:

  1. cd /usr/bin - changes directory to usr/bin

  2. sudo rm adb - this will remove adb

Now go back to your previous terminal.

Enter command:

sudo cp adb /usr/bin - this will copy your existing adb from platform-tools directory to usr/bin where you deleted another version of adb.

now if you run: scrcpy

Terminal will show a log that you don't have adb installed.

Go back to your terminal and run: vim .bashrc

If you don't have vim installed on your machine, enter: sudo apt install vim

Press 'i' key on your keyboard to insert path: export ADB='/usr/bin/adb'

ctrl + shift + v to paste it in terminal

Press 'esc' key on your keyboard and type a colon : or shift + ; type x and hit 'enter' key to save.

run: scrcpy

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mahbubur Rahman
Solution 2 Nhut Pham
Solution 3 Farioso Fernando
Solution 4 Javohirbek Ergashboyev
Solution 5 Dids