APK errors

adb server version mismatch

Error text

adb server version (41) doesn't match this client (39); killing...
adb server is out of date. killing...
error: could not install *smartsocket* listener

Cause

The computer has several copies of adb. One starts the server, another tries to connect with a different version, and they kill each other.

Step-by-step fix

  1. Find all adb copies with which -a adb or where adb.
  2. Compare versions with adb version.
  3. Keep only the Android SDK's platform-tools/adb and put it first in PATH.
  4. Run adb kill-server, then start with the single copy.
  5. If an emulator, Genymotion or another tool uses its own adb, point it to the same copy.

Example commands

which -a adb
adb version
adb kill-server
sdkmanager "platform-tools"
export PATH=$ANDROID_HOME/platform-tools:$PATH

How to prevent it

Update platform-tools with sdkmanager and remove hand-copied adb files.

Author and license: Nibras Code