78

I just installed Android Studio. How do I get into root shell on my phone? Or do I have to download ADB separately?

4 Answers 4

67

Android Studio does not contain ADB, you need Android SDK / Android SDK platform tools for it (it is installed on first run of Android Studio).

If you don't want to use Android studio, just download standalone Platform tools and extract to some folder.

ADB is by default located in sdk\platform-tools:

%USERPROFILE%\AppData\Local\Android\sdk\platform-tools\adb.exe

C:\Users\<user>\AppData\Local\Android\sdk\platform-tools\adb.exe.

It's possible to add to PATH in Windows and use Terminal inside Android Studio only by command: adb shell and after use su get root shell.

  1. Locate the SDK platform tools folder (e.g. %USERPROFILE%\AppData\Local\Android\sdk\platform-tools\)
  2. Open Enviroment Variables in Windows (See http://www.computerhope.com/issues/ch000549.htm)
  3. Add the platform tools path (e.g. %USERPROFILE%\AppData\Local\Android\sdk\platform-tools\) to the PATH variable
  4. (optional) Reopen Android Studio
  5. Use Terminal with adb shell command

When you don't want to use it inside Android studio, you can use it just in command line / terminal by: C:\Users\<user>\AppData\Local\Android\sdk\platform-tools\adb.exe

0
92

WINDOWS: In the current version of Android Studio, ADB.exe is located in %USERPROFILE%\AppData\Local\Android\sdk\platform-tools\. Earlier versions of Android Studio have it in %LOCALDATA%\Android\sdk\platform-tools instead.

MAC: Find the ADB executable in ~/Library/Android/sdk/platform-tools.

To open the ADB shell: Ensure Android Studio is installed. In the command line interface (CLI) for your platform -- Command Prompt for Windows or Terminal for Mac -- navigate to the location of the ADB executable as described above (you can copy/paste the strings as shown and don't need to type in your actual username) and do the following:

  1. Type adb devices and press Enter.
  2. Locate the name of your device in the list.
  3. Type adb -s XXXX shell and press Enter, replacing XXXX with the name of your device from the previous step.
0
8

On a Mac Android Studio installs adb there:

/Users/<your username>/Library/Android/sdk/platform-tools

To use it in your shell, you can add it to your .profile file:

export PATH=/Users/<your username>/Library/Android/sdk/platform-tools:$PATH

Please open a fresh terminal window after you did that, or load the changes by typing this in your terminal:

source ~/.profile
0
2

Once you have Android Studio set up make sure you can connect to an emulator or a device where it will be listed in the AVD (Android Virtual Devices). If a physical device is connected confirm that debugging mode is enabled and access is allowed to Android Studio. A separate ADB is not needed as all the build tools are part of the IDE.

Now you are ready to access your device's shell!

  1. Access the terminal at the bottom of the IDE by selecting the Terminal button.

  2. In the terminal issue adb devices. This will list the all devices currently connected to Android Studio. Find and use your device's name for step 3.

  3. Now issue adb -s <device-name> shell. Now you are in your device's shell.

On a side note, if you want to access the shell of an emulator with root access installed from Android Studio, issue a adb -s <device-name> root before accessing the shell.

2
  • After "adb -s <device-name> root" how to exit then get in again with non-root user? Getting in again with shell the user is still root.
    – jw_
    Oct 22, 2019 at 4:44
  • 1
    @jw_ adb -s <device-name> unroot :)
    – NocTurn
    Oct 22, 2019 at 22:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .