How to open adb and use it to send commands - android

I use ADT to try to make android apps, and use AVD. I know there is another tool called adb. I know it has been installed, and I want try to use it to send commands. Where is it? How to open it? Which button is used to open ADB in ADT?
Another question is where are the API documents? How to find it except on the website, like download or whatever?

You should find it in :
C:\Users\User Name\AppData\Local\Android\sdk\platform-tools
Add that to path, or change directory to there. The command sqlite3 is also there.
In the terminal you can type commands like
adb logcat //for logs
adb shell // for android shell

In Windows 10 while installing Android SDK, by default latest SDK gets installed.
Platform List is part of Android SDK and the best way to find the location is to open SDK manager and get the path.
It will be available at:
Android SDK Location: C:\Users\<User Name>\AppData\Local\Android\sdk\platform-tools\
In SDK Manager, SDK path can be found by following the below
Appearance & Behaviour --> System Settings --> Android SDK
You can get the path where SDK is installed and can edit the location as well.

If you have downloaded the AS + SDK bundle: in Windows 10
C:\Users\ your User Name \AppData\Local\Android\sdk\platform-tools\
Run adb.exe
Type adb shell.
Now able to access adb and the db.

The adb tool can be found in sdk/platform-tools/
If you don't see this directory in your SDK,
launch the SDK Manager
and install "Android SDK Platform-tools"
Also update your PATH environment variable to
include the platform-tools/ directory, so you can
execute adb from any location.

The short answer is adb is used via command line. find adb.exe on your machine, add it to the path and use it from cmd on windows.
"adb devices" will give you a list of devices adb can talk to. your emulation platform should be on the list. just type adb to get a list of commands and what they do.

Check out Android Documentation Managing Virtual Devices

Related

bash: adb: command not found in Windows 10

I have installed adb.exe and other files and folders from platform-tools inside of /c/adb/platform-tools/adb.exe in a Windows 10 machine, but I am unclear as to what should happen next and a result I am not sure if it's a step I am missing or if the employer has put a block on the machine they issued to me.
What steps do I need to take to get adb devices working? This way if it still does not work then I know I need to let their IT team know they need to unblock whatever it is that is keeping me from utilizing adb devices.
There is this guide here: https://docs.expo.io/workflow/android-studio-emulator/
but the folder file structure is geared towards a unixy system and even when I run ./adb version I get permission denied.
I went into environment variables and added to my Path: C:\adb\platform-tools\adb.exe, but when I run adb devices or adb version I still get command not found.
In order to use it from anywhere, you must add the folder in which adb is located to your PATH environment variable.
Otherwise without adding that, you can go to that folder on terminal ( cd /c/adb/platform-tools/adb.exe ) and use it from there.

How to list the available Android Virtual Devices (AVDs)

I'm trying to follow What is the command to list the available avdnames, but I'm missing a bit of context. I gather that the command
android list avd
needs to be typed into a command-line interface (presumably the Android Debug Bridge (adb)), but how do I start up this interface? I've installed adb and but if I simply type it as a command at the command line, only a manual is printed.
Update
Following the answer given, I went to the ~/Android/Sdk/tools (I used the default location during installation) and ran ./android list avd (see below). (There are other errors, but at least the command works).
Move to the directory where you have installed Android SDK.
Move inside Tools folder and write command android list avd
Info update, selected solution works but its deprecated, nowadays you should use:
cd ~/Android/Sdk/tools
./bin/avdmanager list avd

Could not automatically detect an ADB binary - Android Studio

I tried testing my app on Android Studio but I was getting stuck at
"waiting for AVD to come online..."
I've read resetting adb from Android Device Monitor will do it, and it did...
for 1 test, when I've restarted my PC the next day I'm getting not only:
"waiting for AVD to come online..."
but also
"Could not automatically detect an ADB binary." error every time I try testing my app.
Maybe worth mentioning when I did that 1 test, I was also getting the
"Could not automatically detect an ADB binary."
error, but at least it worked.
Just open the emulator and click on the three dots on the last of the toolbar line, the other page will open then go to setting, then there is the the option "USE DETECTED ABD LOCATION" just off that than the option will come click on that and select adb.exe the location of adb.exe is go to your main disk location example my main disk location is C:\ just select your own disk where your windows, mac, linus is installed,then go to users, then AppData, then Local, then Android then select sdk then platform-tool and select adb.exe then click ok
From my experience this is because the AVD can't detect your ADB binary. When you launch the AVD if you go into settings, it's the '...' symbol on the toolbar of the virtual machine, then go to the 'Settings' section there should be an option called 'Use detected ADB location' switch this off then select the location of your adb binary. In Linux you can do this by typing the command:
which adb
Select the location shown in the settings. Once you've done that the error should stop appearing.
This error because android studio did not find adb.exe in SDK\platform-tools folder. Maybe this is caused by sdkmanager while trying to update current packages.
Any way, the easiest way to fix this error is by downloading SDK Platform Tools as zip file from https://developer.android.com/studio/releases/platform-tools.html , unzip it and replace the current platform-tools folder in SDK folder.
go to ..\AppData\Local\Android\Sdk\platform-tools and reinstall your ADB, i guess this happens on ADB 32 in an system 64bits
Go and check your sdk/platform-tools, is adb there? If not Open SDK manager and download Android platform tools, contains adb.
After that try once again, for me this works
On my device (Windows 10 x64) it is located at:
C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
Click on the ... in the emulator and click on settings -> "User detected ABD location" will be switched on. Change it to off and browse the location of adb.exe under platform tools.
download platform-tools from :
https://developer.android.com/studio/releases/platform-tools
Extract files and
copy platform-tools folder to location :
C:\Users\User-Name\AppData\Local\Android\Sdk
overwrite all files

'adb' is not recognized as an internal or external command, operable program or batch file

I am trying to run google map v2 on emulator, I am following this tutorial.
When I was trying to install required apk file on emulator, I am getting below error.
I tried to solve this using this tutorial.Followed all steps, added the path to paltform-tools to environment path. Also after modifying the PATH variable started a new CommandPrompt window.
But getting the same error. I need to check my google map application on emulator.
Kindly suggest me.
'adb' is not recognized as an internal or external command,
operable program or batch file.
Set the path of adb into System Variables. You can find adb in "ADT Bundle/sdk/platform-tools" Set the path and restart the cmd n then try again.
Or
You can also goto the dir where adb.exe is located and do the same thing if you don't wanna set the PATH.
If you wanna see all the paths, just do
echo %PATH%
From Android Studio 1.3, the ADB location is at:
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools.
Now add this location to the end of PATH of environment variables. Eg:
;C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools
If you want to use it every time add the path of adb to your system variables:
enter to cmd (command prompt) and write the following:
echo %PATH%
this command will show you what it was before you will add adb path
setx PATH "%PATH%;C:\Program Files\android-sdk-windows\platform-tools"
be careful the path that you want to add if it contains double quote
after you restart your cmd rewrite:
echo %PATH%
you will find that the path is added
PS: if you just want to add the path to cmd just to this session you can use:
set PATH=%PATH%;C:\Program Files\android-sdk-windows\platform-tools
I did this on Windows 7, by going to:
Start > Control Panel > System > Advanced System Settings > Environment Variables...
In this Environment Variables window, in the User variables for (your-username) highlight Path and click Edit...
You then need to append a ; if there isn't already one at the end of the Variable value field, and then append C:\Users\<your-username>\AppData\Local\Android\sdk\platform-tools; to that same field.
Then click the three OK buttons to get out.
If you already have a Command Prompt window open, close it then re-open and the adb devices command should then work.
In Windows 10,
Add User Variable PATH: %USERPROFILE%\AppData\Local\Android\sdk\platform-tools.
Restart cmd (if any open).
adb devices, it should list, if it does, you are all set.
That's it!
On Window, sometimes I feel hard to click through many steps to find platform-tools and open Environment Variables Prompt, so the below steps maybe help
Step 1. Open cmd as Administrator
Step 2. File platform-tools path
cd C:\
dir /s adb.exe
Step 3: Edit Path in Edit Enviroment Variables Prompt
rundll32 sysdm.cpl,EditEnvironmentVariables
more, the command to open environment variables can not remember, so I often make an alias for it (eg: editenv), if you need to work with environment variables multiple time, you can use a permanent doskey to make alias
Step 4: Restart cmd
Add your path into environment variable "PATH" where you installed your sdk with below:
\Sdk\platform-tools
You can in image below for example:
and reopen your command prompt to see changes.
Follow path of you platform tools folder in android setup folder where you will found adb.exe
D:\Software\Android\Android\android-sdk\platform-tools
Check the screenshot for details
If your OS is Windows, then it is very simple.
When you install Android Studio, adb.exe is located in the following folder:
C:\Users\**your-user-name**\AppData\Local\Android\Sdk\platform-tools
Copy the path and paste in your environment variables.
Open your terminal and type: adb it's done!
adb command can be under the new path below-
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools
for new versions of Android studio.
I found in this location for me.
For environment variable, we have to need to follow some steps.
just open Android studio and press "Tools" on Top navigation bar
tools->SDK Manager
Where you can get SDK location
Open SDK folder -> platform-tools
You will need to set the PATH variable pointing to the directory where adb.exe is to be found. If you are using cmd.exe, this command will help:
set PATH=%PATH%;%USERPROFILE%\appdata\Local\Android\sdk\platform-tools
1st: goto the drive where your eclipse reside and goto sdk and platform tool in my case C:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools
2nd:copy that address for ease of access
3:open command prompt win+r and type cmd hit enter
4:paste the address in cmd and hit enter thats all
In new version PowerShell, after all steps that mentioned before this, please attend:
before
adb
now
.\adb
I recommand you using PowerShell
Set Android Studio Terminal to PowerShell:
Settings > Tools > Terminal > Shell path = pwsh.exe (instead of cmd.exe)
Open Terminal on Android Studio
PowerShell 7.0.1
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
PS >
Test the path for adb.exe
# `pikachu` should be replace your username
PS > test-path "C:\Users\pikachu\AppData\Local\Android\sdk\platform-tools"
True
Open your powershell profile file in your text editor
PS > notepad $profile
add below line, save and exit
# `pikachu` should be replaced with your username
$env:PATH+=";C:\Users\pikachu\AppData\Local\Android\sdk\platform-tools"
re-open Terminal and try adb
PS > adb
Android Debug Bridge version 1.0.41
Version 30.0.1-6435776
Installed as C:\Users\hdformat\AppData\Local\Android\sdk\platform-tools\adb.exe
global options:
-a listen on all network interfaces, not just localhost
-d use USB device (error if multiple devices connected)
-e use TCP/IP device (error if multiple TCP/IP devices available)
-s SERIAL use device with given serial (overrides $ANDROID_SERIAL)
-t ID use device with given transport id
-H name of adb server host [default=localhost]
-P port of adb server [default=5037]
Based on Vamsi Tallapudis earlier answer I came up with this dynamic path:
%LOCALAPPDATA%/Android\sdk\platform-tools
It's using a Windows Environment Variables. I find this solution to be both elegant and easy and would therefor like to share it.
Since I installed version 1.0.41,
I had to use the command "adb version" instead of "adb –version", in Windows 10.
Check and add these below loacations to the path variable:
C:\Users\Sameera\AppData\Local\Android\Sdk\tools
C:\Users\Sameera\AppData\Local\Android\Sdk\platform-tools
C:\Users\Sameera\AppData\Local\Android\Sdk\build-tools
ANDROID_HOME
C:\Users\Sameera\AppData\Local\Android\Sdk
I had same problem when I define PATH below
C:\Program Files (x86)\Java\jre1.8.0_45\bin;C:\dev\sdk\android\platform-tools
and the problem solved when I bring adb root at first.
C:\dev\sdk\android\platform-tools;C:\Program Files (x86)\Java\jre1.8.0_45\bin
In my case it was:
C:\Program Files (x86)\Android\android-sdk\platform-tools
This is where I found it:
C:\Users\<USER>\AppData\Local\Android\sdk\platform-tools
I had to put the complete path into the file explorer. I couldn't just click down to it because the directories are hidden.
I found this path listed in Android studio:
Tools > Android > SDK Manager > SDK Tools
This answer assumes that the PATH has been correctly set as described in the other answers.
If you're on Windows 10 and don't have Admin rights, then right click on the CMD, powershell ... program and select run as administrator. Then try adb [command]
First select drive that is where Android sdk folder is there. Then you Follow the below steps
cd DriveName:/ or Ex : cd c:/ Press 'Enter'
then you will give the path that is adb console path is there in a platform-tools folder
so
cd Root Folder/inner root folder if there/Platform-tools Press 'Enter' then it selects the adb directory.
If you didn't set a path for ADB, you can run .\adb instead of adb at sdk/platformtools.
It seems that Avast antivirus detects adb.exe as a virus and adds it to it chest
For those using macOS, this osxdaily.com article shows several ways to add adb to the $PATH.
Here's the one I prefer:
Add a file named adb to /etc/paths.d/ folder that just contains the path to adb's location: /Users/YourUserName/Library/Android/sdk/platform-tools/
In a Terminal window, sudo vim /etc/paths.d/adb
-> enter the path and save the file.
Close/re-open Terminal in order for it to see the change.
You could just drag the adb.exe on to the command prompt from sdk/platformtools and leave a space and type the command you want: like logcat.
It looks like this for me:
C:\adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\sdk\platform-tools.exe logcat
and hit enter.

How to install an application on android emulator?

When i enter "adb install asdasd.apk" to cmd returns "error:device not found". How can I fix this?
Just copy that apk file into ( D:\android-sdk\platform-tools ) android sdk platform tools.
and then open the cmd prompt.
then, come into that platform tools path in cmd prompt.
then, give like this in cmd -- adb install (appName).apk
wait few minutes and get success respomse in cmd prompt..
First, familiarize yourself with a concept of AVD. That's basically an instance of the emulator - it has a bunch of settings, like the Android version to use and screen size and an SD card image.
You cannot install stuff "in the emulator" - you can only install stuff into a specific AVD. For that, you need to create and run an AVD first. For that, use "AVD Manager" from Eclipse or standalone.
Under the Android SDK folder in Explorer, run "AVD Manager". Choose an AVD (or create a new one if you don't have any). Select, click "Start".
Does the emulator show up when you run the following command?
adb devices
If not, you might have to boot up the AVD first, but if I remember correctly it should be starting it up by itself.
Have you created a new emulator for your project? And are you using Eclipse? Eclipse has an ADT plugin which is useful as it allows you to open the AVD manager through it. This plugin will give you this option in the Windows tool bar of Eclipse: Windows>AVD manager.
Create a new project based on the emulator and click the run button which will install your project onto the emulator. If you have an Android device I recommend turning USB development mode in your phones settings and running your project straight onto your device as it will be a lot faster. Hope this helps
this is what i did :
first run the "AVD Manager"-> choose an AVD -> click "Start"
immediately after
you click on "Start"
use command on cmd as,
adb install asdasd.apk
then in my case (Windows), asked to place .apk file in data/local/tmp/
what i did was copy and paste .apk file into data/local/tmp
and again use command
adb install asdasd.apk
then cmd prompted-> Success
You can also use command
adb devices
command for check whether emulator is in the list
Actually you may need to run AVD several times

Categories

Resources