skip to Main Content

I am running Linux Mint Cinnamon, version 21.3. I just wanted to practice running the adb command from the command line in Android Studio Hedgehog (2023.1.1 patch 2), but I keep getting sh: adb: command not found whenever I type any adb command.

I ran sudo apt install adb, and it’s been installed in /usr/lib/android-sdk/platform-tools. I see the adb executable in there.

Then, I went to File Settings->Tools->Terminal in Android Studio,

Terminal Settings Start Directory

and I set the Start Directory to /usr/lib/android-sdk/platform-tools. It did not make a difference. I wonder if I need to change the Android SDK location to this, but I feel hesitant to disrupt some of these defaults, being a relative newcomer to Android Studio. Also, Android Studio doesn’t even see this directory; I pasted it in there, but it’s impossible to actually navigate to it, as it’s invisible from Android Studio. I set the $PATH environment variable to include the platform-tools folder, and it does, but I wonder if there is another $PATH variable that’s specific to Android Studio, and whether there’s a PATH subsystem in the IDE itself that’s not related to what I set up in my .bashrc file.

2

Answers


  1. Chosen as BEST ANSWER

    I did get it to work after I added a couple of export lines to my .bashrc file (sudo nano ~/.bashrc to make changes. Then CTRL+O to save and source ~/.bashrc to load the file):

    export ANDROID_HOME=$HOME/Android/Sdk

    export PATH=$PATH:$ANDROID_HOME/platform-tools

    Then, I went to File..Terminal in Android Studio and looked at the Shell Path text box. It had /bin/sh shell which means that the Android Studio was using sh shell, while I was using bash. I changed it to /bin/bash. I restarted the Android Studio, and the adb command started to work!

    One thing I also did, which I do not know whether it helped or not was to go to Tools...SDK Manager in Android Studio and pick the "SDK Tools" tab. I noticed that Android SDK Command-Line Tools and Android SDK Platform-Tools weren't installed, so I installed them. This was the first thing I did in order to attempt to fix the problem, but this step by itself didn't fix anything. The adb utility had already been installed on my system prior to checking the command line and platform tools checkboxes, but this step might have helped in conjunction with the other two.


  2. You could try setting ANDROID_HOME (key) pointing to /usr/lib/android-sdk (Environment Variables field). You may need to exit/re-start Android Studio for this to take effect).
    PS: Did you do a sudo apt install adb as the current user (vs some other root account)?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search