Android adb won't let me enter commands - android

I'm trying to deal with some SQLiteDB issues and wanted to use the ABD tool to access my emulators database. When I click on the adb file in the platform-tool file, it opens up but very quickly throws a bunch of text on the window and then closes. Its so fast I can't even tell what it is doing. I tried running as administrator and it didn't change. I'm using Vista if that has anything to do with it.
Any suggestions for how I can even get it to stop from closing so I can enter a command?

You start the command shell (WindowsKey + R, enter cmd in the window that appears and hit Enter.), then use it from there. adb shell is probably the command you need.
C:\> cd \Path\to\platform-tools
C:\Path\to\platform-tools\> adb shell
if you add the path to your environment PATH you don't need to cd there. [This] should be a good example how to do that.

As mentioned by zapl, you need to launch command prompt, add adb directory to path and then running adb commands. You may also be able to pull the trick with DDMS.

In the answer, it was not clear that you have to run a windows cmd.exe terminal program first. Make sure you are in the correct directory, Then start ADB from within this cmd program.
To ensure that windows can find adb.exe ("being in the correct directory), you can either navigate to the location of the adb.exe (usually Platform tools) manually using "cd" command, or update your path statement so that windows can find it regardless of where your cmd.exe prompt is pointing.

Related

How to terminate adb.exe on windows? What keeps restarting it?

I am trying to terminate adb.exe on my Windows machine. I am using taskkill /F /IM adb.exe /T to do this. However each time I do it, 3 adb.exe instances come back into the task manager process view. Something is restarting them.
I'm trying to do some connection-between-virtual-machine stuff and I need adb.exe to die and stay dead on the Windows host, because it is interfering.
How do I identify what is restarting these processes? Or otherwise make adb.exe stay dead without doing extreme stuff like temporarily deleting it from the Windows host?
Extra notes:
When I run the taskkill, a process group called "Service Host: DCOM Server Process Launcher" jumps to the top of the process list at 20% cpu, so maybe it's what is responsible.
No, adb kill-server etc is no more effective.
It may help you if you look at process explorer. It resolves process trees and may lead you to the starting process.
https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx
However, if I start the adb server through a command promt, it shows adb.exe as subprocess of cmd.exe only for some seconds and then gets handed up as independend process. You might want to have the process explorer open and monitor the restarting procedure of adb.exe.
To kill adb you can use adb kill-server and start it with adb start-server
adb.exe is platform-tools folder in your Android SDK.
Also you can get it from chocolatey packages https://chocolatey.org/packages/adb
I had the same issue. In my case it was a gradle daemon who was keep restarting an adb server. To prevent him doing so, I used gradle --stop.
For anyone with a similar issue:
When using flutter, check if you have two adb.exe executables.
Run cmd
Type cd.. to exit current directory
Comes to the main directory i.e.C:> directory
Now type adb kill-server and press enter
Now go to the adb directory means the path where adb is located ex.-> [your path]\AndroidStudioProjects\sdk\sdk\platform-tools
Delete the adb.exe
Download latest platform-tools from here
Unzip it
copy the complete folder and paste inside [your path]\AndroidStudioProjects\sdk\sdk\platform-tools
For Windows users:
Simply Open TaskManager --> Processes --> Background processes --> Select ADB --> End Task.
It will stop ADB from running in the background.
My Android Studio has an adb file inside /home/myuser/Android/Sdk/platform-tools/ with the version 1.0.41.
Note where I put myuser could be your name, whatever, just locate your Android path.
My error was:
adb server version (41) doesn't match this client (39)
When you type just adb in terminal, this command will be related with the adb archive inside /usr/bin.
So, I did these steps inside terminal:
adb version
Android Debug Bridge version 1.0.39
cd /usr/bin
sudo rm adb
cd /home/**myuser**/Android/Sdk/platform-tools/
Please check if there is an adb file inside your path
Now copy to /usr/bin
sudo cp adb /usr/bin
adb version again
Android Debug Bridge version 1.0.41
With this done, both of them have the same adb file.
If in the future the SDK Manager asks to upgrade platform-tools and the error appears again, remember to perform these steps again.

Run ADB shell on OS X

I want to enter a simple adb shell command, so I navigated to ...\sdk\platform-tools\adb.exe, and opened it. However, I am unable to type in it!
What is the solution?
.exe files are executable files for the Windows OS. They will not work on OSX.
There is a program called Terminal that is installed in OSX that you can use to run the adb shell command. You must open up a Terminal and navigate to the directory that is shown in your screenshot, and then you can run the command
./adb shell and it should work.
Alternatively, you can use the Terminal in Android Studio to perform the same operation.
Here is how I change my directory to platform-tools on a mac terminal:
Search the finder for "platform-tools". Then right-click on it, and left-click on "get info". You'll see a little window pop up with all the info for that folder.
Copy the "where", which is the file path.
Then paste into your terminal like this:
cd /Users/[user-name]/Library/Android/sdk/platform-tools
Be sure to add /platform tools on after pasting the path to the folder.
Then hit return. Your terminal should then be pointed to that folder and you can invoke the adb commands by using "./adb [whatever command]".
Or you can invoke adb shell commands: for example let's say you want to enable Analytics Debug mode on an Android device. Use the following command:
adb shell setprop debug.firebase.analytics.app [your_package_name]

ADB will not run

I just installed the android SDK with eclipse, straight from google's webpage, but for some reason it won't run, even when I am in the correct directory. When I use 'ls' (crunchbang linux) it show's that the file is there, but when I try to run it, it returns no such file or directory. Any ideas?
type script in your command if you adb configured.
adb stop-server
adb start-server
adb devices

AppleScript "do shell script" ignores PATH Variable

I'm trying to build an automated build script with applescript on MacOS X.
For now everything works correctly with one glitch.
The command "do script ("zipalign -f -v 4 /tmp/src.apk /tmp/tgt.apk") works fine if I run it in a separate tell for application "Terminal" but leaves the terminal window open when it's done. Everything else in the script works fine in tells for application "Finder".
If I try to run the command via "do shell script" inside the tell for "Finder" I only get an error "command not found".
The path to zipalign is set in /etc/paths and is reachable through any terminal window and "do shell" but not to "do shell script" command.
What is the correct way to ensure that "do shell script" uses $PATH to find commands or alternatively is there a bulletproof way to close the terminal left by "do script"?
When you invoke bash as an interactive login shell, the paths in /etc/paths and /etc/paths.d/* are added to PATH by /usr/libexec/path_helper, which is run from /etc/profile. do shell script invokes bash as sh and as a non-interactive non-login shell, which does not read /etc/profile.
You can run path_helper manually though:
do shell script "eval `/usr/libexec/path_helper -s`; echo $PATH"
Though this question was four years ago, but I think the simplest answer is needed to be told. I use the command 'wkhtmltopdf' (which is used to print pdf and it is placed in /usr/local/bin) for example
--past
wkhtmltopdf out.html out.pdf
--now
PATH=$PATH:/usr/local/bin; wkhtmltopdf out.html out.pdf
It just add new PATH variable to the sh process called up by AppleScript.

Android: adb pull file on desktop

Trying to copy file from device to desktop, here is a command:
adb pull sdcard/log.txt Users/admin/Desktop
But this command creates a folder Users/admin/Desktop inside platform-tools folder where adb is located. How to pull file to my desktop ?
Use a fully-qualified path to the desktop (e.g., /home/mmurphy/Desktop).
Example: adb pull sdcard/log.txt /home/mmurphy/Desktop
Judging by the desktop folder location you are using Windows. The command in Windows would be:
adb pull /sdcard/log.txt %USERPROFILE%\Desktop\
Be root, Define file on device and define new filename.
adb root
adb pull /data/data/.../databases/launcher.db launcher.db
On Windows, start up Command Prompt (cmd.exe) or PowerShell (powershell.exe). To do this quickly, open a Run Command window by pressing Windows Key + R. In the Run Command window, type "cmd.exe" to launch Command Prompt; However, to start PowerShell instead, then type "powershell". If you are connecting your Android device to your computer using a USB cable, then you will need to check whether your device is communicating with adb by entering the command below:
# adb devices -l
Next, pull (copy) the file from your Android device over to Windows. This can be accomplished by entering the following command:
# adb pull /sdcard/log.txt %HOME%\Desktop\log.txt
Optionally, you may enter this command instead:
# adb pull /sdcard/log.txt C:\Users\admin\Desktop\log.txt
List item
Use following command to pull data from ADB
adb pull data/user/0/project package name/files/.local/share/dbname C:\Users\vijayalaxmi.k
data/user/0/project package name/files/.local/share/dbname this path you will get when you debug application. i.e database path
project package name example => com.example
instead of C:\Users\vijayalaxmi.k user your own path where you want to save your file. for example, c:\documents
do adb pull \sdcard\log.txt C:Users\admin\Desktop

Categories

Resources