[WINDOWS][TUT]ADB tutorial, setting up ADB, usefull commands, collecting debug info. - Samsung Galaxy R i9103

Hi all.
Everyone here on our forum wants to help devs by testing different stuff but devs wants testers to send debug info to them so they can resolve bugs. Notifying bugs without logcats is useless and some users don't know how to collect these debug data.
To collect debug info there is a tool named ADB (Android Debugging Bridge). we r very small community and there are not plenty of sgr users around here so we have to worry about knowledgeable testers. so i m making this basic instructional guide to ADB. about how to set up ADB on windows and some basic usage.
Setting up ADB on windows.​
Know this first.
> ADB requires usb drivers. So first of all install kies so that ur pc detects ur phone and ADB can recognise ur phone.
> Android is linux based and in linux commands are case sensitive so while typing these command use propare case otherwise commands won't execute.
> Windows uses back slash [\] and linux uses forward slash [/] so while typing file locations. For location of file in ur pc use back slash and for files in ur phone/sd card use forward slash.
there are two ways to setup adb on ur windows pc.
1 > download the android sdk, it includes the adb
u can download latest android sdk from HERE.
2 > only download adb package, no need of downloading the whole sdk.
look at the end of post to find the zip file of adb package.
now after downloading:
if u have downloaded sdk read this:
> after downloading sdk, extract it to ur desired location.
> after extracting, open that folder and goto "platform-tools" folder.
> now hold the shift key and hit right click in that directory
> click "open command window here"
> u will see command promp, type "adb" in command prompt. if adb executes means u have successfully setup adb on ur windows.
if u r using without sdk:
> just extract the package
> hold shift key, hit right click and choose "open command prompt here"
> type "abd" in command prompt and check if adb executes.
now as we have successfully setup adb lets begin to some basic commands.
first of all connect ur phone using usb cable. make sure u have checked usb debugging in settings>applications>development>check usb debugging.
now open adb as mentioned above and type
Code:
adb devices
u should see
Code:
list of attached devices
xyz device
xyz will be name of ur device, as default it will be some number.
Basic usefull ADB commands​
1.
Code:
adb pull
this command can be used copy files from ur device to ur pc.
for eg.
Code:
adb pull /system/app/Camera.apk
this will copy the camera app to the directory where adb is extracted.
if u know the path u can copy anything using this command.
2.
Code:
adb push
this command can be used to push files to ur phone.
type the command, drag and drop the file in command prompt and than type location where u want to push that file and hit enter.
for eg, if i want to push image named android.jpg stored in my C drive.
Code:
adb push C:\android.jpg /sdcard/
this will push that image to sdcard.
sometimes we have to push some packages in specified folders. just type the location after file name.
for eg
Code:
abd push C:\sanim.zip /system/media
3.
Code:
adb install
with help of this command we can install apps to our phone dorectly from pc.
for eg. type "adb install" than leave one space with mouse choose apk file of app u want to install and drag and drop it in command prompt. path of that app will be displayed in command prompt. like this.
Code:
adb install C:\adb\Camera.apk
by executing this command u can install the app u have dragged and dropped in command prompt.
As i have written for windows but these commands can be used on ADB on linux/MacOS as well but i have only mentioned the set-up guide for windows only.
Credits/Source.​
http://developer.android.com/tools/help/index.html

Getting Debug Infos (Logcats)​
1. logcat
logcat is a report from android logging system which runs in background from the moment u boot ur phone. and it haves all the info what went wrong with system.
generally we can see logcat by typing
Code:
adb logcat
but that will show the constant data flow so better save it as file so can be sent to dev or u can study it later.
Code:
adb logcat > log.txt
this will store the logcat to directory of adb and collect log in text file.
2. bugreport
Code:
adb bugreport
bug report prints dumpsys, dumpstate, and logcat data to the screen. which can be used for bug reporting.
3. Java Debug Wire Protocol
Code:
adb jdwp
this command prints the list of available JDWP processes on connected device in command prompt.
Logcats On Mobile​u can directly generate logcat on ur mobile using Terminal Emulator app, there are many terminal apps in market. CM comes with pre-loaded Terminal Emulator.
some terminal apps:
Android Terminal
Terminal Emulator
RomToolbox
u will need root access to generate logs
open terminal app, u will see following screen
Code:
$ export PATH=/data/local/bin:$PATH
$
now type su and hit enter.
allow super user permissions.
now to get a logcat type following command.
Code:
logcat > /mnt/sdcard/logcat.txt
this will generate text file named logcat.txt on root of ur sdcard which is containing logcat.
to get DMESG (Kernel Debug)
open terminal and type following command
Code:
su
dmesg > /mnt/sdcard/dmesg.txt
this will generate text file named dmesg.txt on root of ur sdcard which is containing kernel debug log.

Kernel Debugging.​
we can use adb to debug kernel issues.
Code:
adb shell
dmesg
this will generate a log which is very helpful to resolve kernel issues, we just have to send this log to dev, he will look after it.
sometimes after flashing kernel we go into bootloop in that cases generate logcat using this commands and send to dev it will be very helpfull for dev to know and resolve reason causing bootloop.
Code:
adb shell
cat /proc/last_kmsg > /sdcard/last_kmsg
this command should be executed immediately on reboot otherwise it will be over written by new kernel message. the file will be stored on root of ur sdcard named last_kmsg. send this file to kernel dev it will help him great to resolve the problem.
Read this if u dont know how to get files from ur sdcard even if ur phone is not booting and stuck at bootloop.
u must have CWM to do this.
>boot ur phone in recovery mode (by holding VOL UP and HOME key together on boot)
>goto "Mounts and Storage"
>Select "Mount USB Storage" and plug in your data cable.
>Now u can access ur sdcard on ur pc, after ur work is done click "Unmount"

Hi,
Just a noob question... if my phone is stuck in a bootloop, is there anyway for me to get a logcat without flashing a new rom???
Sent from my GT-I9103 using xda app-developers app

JoJo2012 said:
Hi,
Just a noob question... if my phone is stuck in a bootloop, is there anyway for me to get a logcat without flashing a new rom???
Sent from my GT-I9103 using xda app-developers app
Click to expand...
Click to collapse
If you have enabled USB Debugging , yes
"I have to go. It's just....they really need me." - Sora

Re: Toggle mobile data on and off via adb
Does anybody know how to toggle mobile data on and off via ADB?? IM WILLING TO PAY FOR THIS INFO lol I NEED IT THAT BAD!! PM ME PLEEEASE!!!!!

12manytimes said:
Does anybody know how to toggle mobile data on and off via ADB?? IM WILLING TO PAY FOR THIS INFO lol I NEED IT THAT BAD!! PM ME PLEEEASE!!!!!
Click to expand...
Click to collapse
'adb shell su -c "svc data disable"' and 'adb shell su -c "svc data enable"'. You must be rooted.
Sent from my GT-I9103 with CM10

Adam77Root said:
'adb shell su -c "svc data disable"' and 'adb shell su -c "svc data enable"'. You must be rooted.
Sent from my GT-I9103 with CM10
Click to expand...
Click to collapse
Thanks alot, i just sent you a PM but it shows that i didn't send anything, so if you didn't get the message please send me one cuz id like to buy you a beer!
I wish i could hit your thanks button a million times right now lol

Hello I am trying to create a batch file that has an infinite loop and was wondering if there are any adb commands that can do this.
I am also looking for an adb command that waits x amount of seconds before performing the next command.?
Any help would be greatly appreciated

Related

getting root using MAC OS ??

Is there any step by step tutorial to get my htc magic rooted
I can only find posts where they say it is like on windows but without installing files but i have no idea how to enter that prompts on terminal
it would be much appreciated any help. I know i am not the only one interested
cesardeluxe said:
Is there any step by step tutorial to get my htc magic rooted
I can only find posts where they say it is like on windows but without installing files but i have no idea how to enter that prompts on terminal
it would be much appreciated any help. I know i am not the only one interested
Click to expand...
Click to collapse
The commands are the same. Just like Linux users can follow Windows directions but with some substitutions.
Download the SDK here: http://developer.android.com/sdk/1.5_r3/index.html
Follow the instructions here: http://developer.android.com/sdk/1.5_r3/installing.html
Once you have the SDK setup, you can follow the steps given in the rooting threads/wiki. Any time it says to enter a command you do it in your terminal (which on OSX i think is Terminal.app, use Spotlight to find it).
Hope this helps a bit.
i dont get this:
Code:
On a Mac, look in your home directory for .bash_profile and proceed as for Linux. You can create the .bash_profile if you haven't already set one up on your machine
i don't have that .bash_profile how do i create it?
thanks
Google easy to use and always there for you.
Clinton
yeah but all tutorials are made for xp or even linux.
I have tried to create it using vi command then edited with the path o the sdk tools
but when i type adb it doesn't do anything
i am stuck there
Did you check my link for your bash_profile ? This help at all?
Clinton
cesardeluxe said:
yeah but all tutorials are made for xp or even linux.
I have tried to create it using vi command then edited with the path o the sdk tools
but when i type adb it doesn't do anything
i am stuck there
Click to expand...
Click to collapse
Try reading this:
http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/
Sounds like the Path variable may be in a different file. It is the same on linux, I think it can be in a few places.
Irf you want to use adb without messing with your path you can do the following:
Code:
cd <android-sdk-location>/tools
./adb devices
This is convoluted so get that PATH working and everything should be nice and easy! Good luck.
I use a Mac, and when I was getting started I used the linux tutorials with no problem.
i can push the 2 files using commands to my sd. Adb devices shows my htc ok
but after i enter to fastboot mode the device is no longe shown
i type
Code:
./fastboot boot recovery-new.img
but the only thing i get is
Code:
-bash: fastboot: command not found
i am on tools directory on terminal
i think fastboot is not in the tools directory ...
i'd rather say the error is caused by that then a missing connection.
Does the phone write "FASTBOOT USB" ?
if you type "ls", can you find a file named fastboot in your directory?
cesardeluxe said:
i can push the 2 files using commands to my sd. Adb devices shows my htc ok
but after i enter to fastboot mode the device is no longe shown
i type
Code:
./fastboot boot recovery-new.img
but the only thing i get is
Code:
-bash: fastboot: command not found
i am on tools directory on terminal
Click to expand...
Click to collapse
The files have to be executable. You can do that by running:
Code:
chmod -R +x /path/to/tools
This makes all the files in the tools directory executable with ./
About the .bashrc or .bash_profile if you don't have one in your home directory you can safely make one. With the following command:
Code:
echo "export PATH=$PATH:/path/to/tools/" > ~/.bashrc
or if the file exists just do:
Code:
echo "export PATH=$PATH:/path/to/tools/" >> ~/.bashrc
Remember to restart the shell after you are done with this.
the reason adb work for you is because adb is in tools directory
fastboot does not. You have to get fastboot somewhere else
Whenever you get command not found, you can run another command to check
ls <program you ran>, and see what happened
Example
in your tools directory, where you have no problem running adb push, try doing "ls adb", without the quote
in your tools directory, where you have problem running fastboot, try doing "ls fastboot", without the quote
and you should see what's going on
BTW, this is fairly basic unix environment. If you are having trouble at this stage, you need to get yourself more familiar with unix environment, which is what osx is based on
I am sorry, but i don't really know where's good tutorial on unix
On google, i just search for "mac osx unix shell tutorial:, and come across this site
http://www.osxfaq.com/tutorials/LearningCenter/
Hope this help
Edit 1: btw, here's where you can find fastboot for MAC. Put it in your tools directory. IF you keep the filename as is, you need to type fastboot-mac whenever you see someone mention fastboot
http://www.htc.com/www/support/android/adp.html
yeah you're right fastboot is not on that tools directory. in fact i have looked into the whole sdk folder and i can't find it.
thanks
hey i managed to apply the update thanks to having fastboot-mac on tools folder
but after booting i go to terminal to apply the final step and i get this
Code:
MBdeluxe:tools cesarleon$ ./adb shell flash_image recovery /sdcard/recovery-new.img
error reading /sdcard/recovery-new.img header: Is a directory
what's wrong ?
thank you people
cesardeluxe said:
hey i managed to apply the update thanks to having fastboot-mac on tools folder
but after booting i go to terminal to apply the final step and i get this
Code:
MBdeluxe:tools cesarleon$ ./adb shell flash_image recovery /sdcard/recovery-new.img
error reading /sdcard/recovery-new.img header: Is a directory
what's wrong ?
thank you people
Click to expand...
Click to collapse
Are u sure that recovery.img got transferred properly? Maybe check the rights on it (it not read only or something). What if you mount the sdcard in OS X and copy and paste (vs push)?
If you're trying to flash the recovery image, try
Code:
adb shell mount -a
adb push recovery-new.img /system/recovery.img
adb push recovery-new.img /sdcard/recovery-new.img
adb flash_image recovery /sdcard/recovery-new.img
Hope that helps
adb shell mount -a
Click to expand...
Click to collapse
didn´t work i think the parameter a is not correct
well this is almost the last step! thank you all for your explanations
cesardeluxe said:
hey i managed to apply the update thanks to having fastboot-mac on tools folder
but after booting i go to terminal to apply the final step and i get this
Code:
MBdeluxe:tools cesarleon$ ./adb shell flash_image recovery /sdcard/recovery-new.img
error reading /sdcard/recovery-new.img header: Is a directory
what's wrong ?
thank you people
Click to expand...
Click to collapse
Very odd error message
Do this to check what your phone's sdcard looks like
Code:
adb shell ls -l /sdcard/recovery-new.img
Next, you should grab the file from your phone to your computer. This step assume you are in your tools directory
Code:
adb pull /sdcard/recovery-new.img recovery-new-phone.img
Finally, try to compare the file you have on your computer against the one you got from your phone, and see if they are the same. This assume you have your working recovery-new.img in tools directory
Code:
diff recovery-new.img recovery-new-phone.img
I have not try this diff command, and I assume it'l handle binary diff
If diff can not handle binary file, do ls and check file size. both file should match
Code:
ls -l recovery-new.img recovery-new-phone.img
If your computer and phone recovery-new.img are not the same, download to phone again
cesardeluxe said:
didn´t work i think the parameter a is not correct
well this is almost the last step! thank you all for your explanations
Click to expand...
Click to collapse
You will get Failed Mounts when u run
Code:
adb shell mount -a
You CAN ignore them.
See here: http://forum.xda-developers.com/showthread.php?p=4029461
This may not be the right way to do it but I always just downloaded the recovery to the tools directory of the android sdk. Then fire up the phone in fastboot mode and do:
./fastboot flash recovery recovery-new.img
(replacing recovery-new.img with the name of the downloaded img file.)
I'm sure there is a reason people are doing it the other way, but for myself one command to do the flash is alot easier!

[Q] ADB doesn't work on Mac

When I CD to the platform-tools folder and type
Code:
adb devices
it says "adb: command not found" If anyone could help me that would be wonderful. I am on the Inspire/DesireHD running AOSP Gingerbread. Thanks!
You have two choices. You can either run the command prefixed with ./ (dot slash), which allows for executing an executable in the current directory:
Code:
./adb devices
Or, the other choice (which will be better if you intend to use adb a lot) is to add the platform-tools folder to your path by editing or creating the file .bashrc in your home folder (~/.bashrc).
Let's suppose your platform tools folder is: ~/.android-sdk/platform-tools
Then, you would want to add something along the lines of the following to your bashrc:
Code:
export PATH="$PATH:$HOME/.android-sdk/platform-tools"
Save the file, the run this or log out/in:
Code:
source ~/.bashrc
Et voila, you should now be able to run adb from any folder without issue.
Explanation: adding the new path (folder) to your PATH environment variable tells BASH to include that folder in its search for an executable. The reason $PATH is added at the beginning of the new string is so that your default path does not get overwritten. $HOME will simply expand to /home/your_user_name when BASH interprets it.
GENIUS! IT WORKED! Thank you! Now, one more question- how do I get superuser privileges using ADB? (device is rooted, of course)
No problem.
On my G1 you were root as soon as you adb'd in. Just tested on my Defy and '$' - shocking. So once you have run adb shell, just run 'su' (without quotes of course) and accept the permission on your phone screen as usual for root programs and you should be good to go.
Sorry to keep asking questions, but when I typed
Code:
su
into adb, it asked for a password. No popup on device screen. I do have superuser installed on the device.
That is odd. I'm not sure why that would be. I'll see if I can think of something though. Hopefully someone else can make a suggestion.
Thanks! You have been very helpful.
Don't think I can hit the thanks button from the app, sorry
Sent from my Inspire 4G using XDA App

[Guide]Noobs Guide to creating a logcat[All methods explained as of 20.1.2013]

Q. What is a logcat?
Ans. A logcat is a sort of written report for what things(operations like starting processes lot of dev related technical things) the phone is doing at a given time.
this guide shall provide simple step by step method (Will try to be very short and direct)
Why create this guide cause i found a lot of guides on this topic(Really a lot !!!)
But were written in a fairly roundabout manner so here is my attempt to simplify things.
Prerequisites : (Please read before doing anything)
For creating a logcat via computer :
1.ADB(Android Debugging Bridge) you can get a smaller version from here : ADB & logcat tools.zip else you can get it along with android SDK.
For creating a logcat via phone :
1.alogcat/catlog[APP]
OR
2.Terminal Emulator.[APP]
Ok down to business...
Via Computer (ADB) :
very useful cause you can start logcatting(Is there such term) even before booting.
open terminal at the location for ADB example for me its C:/ADB>
so now your teminal should look like this :
Code:
C:/ADB>
now connect your phone via USB and don't forget to tick Android Debugging option under app>development(2.3.x) or Developer Option>usb debugging(4.0.x & above) on your phone
now type this in the terminal
Code:
adb logcat -v long > name of problem.txt
nothing will happen on the terminal don't worry its working to end the logcat press ctrl+c.
you shall have a log file called name of problem.txt or whatever you thought of substituting that name of problem with inside your ADB folder.
Via Phone :
1.Via Terminal Emulator :
its same as for adb except you are already in the shell that is rather than doing adb to reach your phone and then command just enter the command simple
type this in your terminal emulator :
Code:
logcat -v long > name of problem.txt
to finish logging press vol down button + c
you will find a text file on your SD Card.
2.Via logcatting(still don't think its a word) APP
here are the links.
1.CatLog
2.aLogCat(free)
Sources :
http://developer.android.com/tools/help/adb.html
http://developer.android.com/tools/help/logcat.html
http://developer.android.com/tools/help/adb.html
and tutorial by paxChristos just a blatant ripoff by me just Noobyfied(is there such a word ???) by me.
If you have any doubts or problem Private message me ...(I do not reply to hate mail,controversies,or doubts that i feel have been adressed to the best of my knowledge here)
Good Luck and hope this helps you to get other developers address your problems convincingly:good::highfive:
good tutoiral you could add some basic adb commands to the op..
Via Phone don't works for me. Do I need to install something before this?
Can we make a logcat through our phone? ?
brady_4u said:
Can we make a logcat through our phone? ?
Click to expand...
Click to collapse
yes, you can do it from phone using terminal emulator!!!
sudarshan_mehta said:
yes, you can do it from phone using terminal emulator!!!
Click to expand...
Click to collapse
What command?
And then can we copy all the data from there? ?
Brady_4love said:
What command?
And then can we copy all the data from there? ?
Click to expand...
Click to collapse
search from google!!! i am too lazy to type all that commands!!!!
which data are you taking about?
Sent from my GT-S5670 using xda premium
taking logcat via phone (apps and terminal) is explained in the first post please look.
if confused pm me.
thankx
Dark Passenger said:
Q. What is a logcat?
Ans. A logcat is a sort of written report for what things(operations like starting processes lot of dev related technical things) the phone is doing at a given time.
this guide shall provide simple step by step method (Will try to be very short and direct)
Why create this guide cause i found a lot of guides on this topic(Really a lot !!!)
But were written in a fairly roundabout manner so here is my attempt to simplify things.
Prerequisites : (Please read before doing anything)
For creating a logcat via computer :
1.ADB(Android Debugging Bridge) you can get a smaller version from here : ADB & logcat tools.zip else you can get it along with android SDK.
For creating a logcat via phone :
1.alogcat/catlog[APP]
OR
2.Terminal Emulator.[APP]
Ok down to business...
Via Computer (ADB) :
very useful cause you can start logcatting(Is there such term) even before booting.
open terminal at the location for ADB example for me its C:/ADB>
so now your teminal should look like this :
Code:
C:/ADB>
now connect your phone via USB and don't forget to tick Android Debugging option under app>development(2.3.x) or Developer Option>usb debugging(4.0.x & above) on your phone
now type this in the terminal
Code:
adb logcat -v long > name of problem.txt
nothing will happen on the terminal don't worry its working to end the logcat press ctrl+c.
you shall have a log file called name of problem.txt or whatever you thought of substituting that name of problem with inside your ADB folder.
Via Phone :
1.Via Terminal Emulator :
its same as for adb except you are already in the shell that is rather than doing adb to reach your phone and then command just enter the command simple
type this in your terminal emulator :
Code:
logcat -v long > name of problem.txt
to finish logging press vol down button + c
you will find a text file on your SD Card.
2.Via logcatting(still don't think its a word) APP
here are the links.
1.CatLog
2.aLogCat(free)
Sources :
http://developer.android.com/tools/help/adb.html
http://developer.android.com/tools/help/logcat.html
http://developer.android.com/tools/help/adb.html
and tutorial by paxChristos just a blatant ripoff by me just Noobyfied(is there such a word ???) by me.
Click to expand...
Click to collapse
Thankx a lot man . Am a newbie and it helped me a lot!!!!! Thanks !!!:highfive::victory::good:
ADB Push
flasherruts said:
Thankx a lot man . Am a newbie and it helped me a lot!!!!! Thanks !!!:highfive::victory::good:
Click to expand...
Click to collapse
Are there any tricks to using ADB push and install? I hae been trying and cannot get it to work.
thanks a lot
Flashing NC2 Kernel
Installed NC4 firmware via Odin 3.09 version and used the safestrap by Hashcode, 3.75, posted on XDA. Installed "Towel Root" as well, but the problem is everytime I attempt to flash NC2 kernel it fails Looking for advice.
Bluedio777 said:
Installed NC4 firmware via Odin 3.09 version and used the safestrap by Hashcode, 3.75, posted on XDA. Installed "Towel Root" as well, but the problem is everytime I attempt to flash NC2 kernel it fails Looking for advice.
Click to expand...
Click to collapse
Sorry mate, you're on the wrong forum. Do you even check the title of OP before posting anything?
That's good work
please help
Dark Passenger said:
Q. What is a logcat?
Ans. A logcat is a sort of written report for what things(operations like starting processes lot of dev related technical things) the phone is doing at a given time.
this guide shall provide simple step by step method (Will try to be very short and direct)
Why create this guide cause i found a lot of guides on this topic(Really a lot !!!)
But were written in a fairly roundabout manner so here is my attempt to simplify things.
Prerequisites : (Please read before doing anything)
For creating a logcat via computer :
1.ADB(Android Debugging Bridge) you can get a smaller version from here : ADB & logcat tools.zip else you can get it along with android SDK.
For creating a logcat via phone :
1.alogcat/catlog[APP]
OR
2.Terminal Emulator.[APP]
Ok down to business...
Via Computer (ADB) :
very useful cause you can start logcatting(Is there such term) even before booting.
open terminal at the location for ADB example for me its C:/ADB>
so now your teminal should look like this :
Code:
C:/ADB>
now connect your phone via USB and don't forget to tick Android Debugging option under app>development(2.3.x) or Developer Option>usb debugging(4.0.x & above) on your phone
now type this in the terminal
Code:
adb logcat -v long > name of problem.txt
nothing will happen on the terminal don't worry its working to end the logcat press ctrl+c.
you shall have a log file called name of problem.txt or whatever you thought of substituting that name of problem with inside your ADB folder.
Via Phone :
1.Via Terminal Emulator :
its same as for adb except you are already in the shell that is rather than doing adb to reach your phone and then command just enter the command simple
type this in your terminal emulator :
Code:
logcat -v long > name of problem.txt
to finish logging press vol down button + c
you will find a text file on your SD Card.
2.Via logcatting(still don't think its a word) APP
here are the links.
1.CatLog
2.aLogCat(free)
Sources :
http://developer.android.com/tools/help/adb.html
http://developer.android.com/tools/help/logcat.html
http://developer.android.com/tools/help/adb.html
and tutorial by paxChristos just a blatant ripoff by me just Noobyfied(is there such a word ???) by me.
Click to expand...
Click to collapse
I followed the steps you gave, but when I try to open powshell in the ADB folder using "shift+right click" the option to open powershell is not there until 100 attempts later... you please tell me what Im doing wrong?

[GUIDE]( Easiest) All about ADB, logcat, shell

ADB:-
Android Debug Bridge
Very useful program made itself by Google for Programmers and developers. Its based on command line and basically communicates with your Android to respond to certain commands. There is vast amount of knowledge about adb but its most useful commands limit to getting:-
Logcat:-
A real time log of what is happening in background of our devices. It is really useful for developers to see which component has malfunctioned and helps to narrow down their search for what failed and what needs to be fixed. Several times users are asked to give logcats of their devices which are giving errors. We will go in detail that how to get logcats in every and easiest way possible.
App Installation and Management:-
adb proves really handy if you want to install apks directly from your PC or want to batch install or delete them.
Shell Execution:-
You must have heard of Terminal Emulator. It is an app for android to execute shell commands(linux commands) which are basically present as applets in /system/bin, /system/sbin or /system/xbin(in our case) folders. A very imporant applet called busybox is installed there mainly used for execution of basic commands during root browsing or ROM installation. Many times updater script of ROMs use busybox commands to install it. Well, these commands can be initiated from your device too but they can be initiated from adb also making it easy for programmers.
Pushing and Pulling:-
Most used commands of adb. adb makes it a piece of cake for new device developers to get an ideo of structure and basic knowledge of devices by pulling command. We can pull out i.e copy any files or folders from our devices to our PC, even the root directories without rooting the devices. It help rooters and ROM chefs of new devices to get an idea and implement their mods on them. Pushing is also very useful command. It copies your files and folders from PC to your device. Very useful in pushing some /system apps and other things
Remounting and setting permissions
Basic commands:-
Of-course basic commands such as reooting and rebooting in recovery ode and download mode are supported.
Others:-
There are several other features of adb such as fastboot, aapt, etc
Setting up ADB
Pre Requirements:-
A little amount of brain
PC(This is a windows guide, if asked I will add linux and mac guide later)
Java Runtime environment or Java Developing kit
Your Device Drivers
An Android Device
Assuming you all these ready and working properly, we continue
If you are having trouble completing Pre-Requisites, there are several guides featuring them too
Start
1. First Download Android SDK. Roughly about 70 MB
2. There may be any compressed zip file or exe file
If zip file, then extract it to C:\android-sdk
If exe file then double click on it and install it in C:\ Drive(or any other drive you want)
3. Now to get adb and other tools, you need to download 'Platform Tools'
To download them, go to the android-sdk folder and double click on SDK Manager
It will ask you which package to download? However, it is your choice which package to Download, but here, we will only talk about platform
Tools. So, simply tick on Platform Tools and click on install. Once you have done it. Go to the platform-tools folder in the directory where you installed android-sdk. You will find several files there like adb, fastboot, aapt, etc
4. Now, you can backup the whole folder of android-sdk to any external storage that will make you not download package
again if you want to. You can have it placed in any computer and run it as it does not require registry to work
5. Now, you are just one step away from using adb. Next step is SKIPPING SETTING ENVIRONMENT VARIABLE
Many guides on internet say that it is to be done for making it easy for users and if you have some basic knowledge of Command Prompt,
you will know that to execute any application with command prompt, you first need to change the directory to the one where application is
placed. And to skip changing the directories every time you open CMD, you need to put that application is environment variable. Howeve, we will not do so.
6. Type cmd in the search bar. Copy cmd.exe from there. Go to the directory where you have installed android-sdk. Go to platform-tools folder. Paste cmd there, right click on it and in the settings, select Run as Administrator.
7. You are done. Now what to do in it?
ADB Commands
Type adb in command prompt. And several commands will show up on your screen. It is very difficult to analyse these all commands, so we will only talk about most used and important commands
Connect your device via USB cable
And open the CMD in platform-tools folder(Make a shortcut of it on desktop). And type the suitable commands
Code:
adb devices
Will show the list of devices attached to the PC andtheir serial numbers. If this shows up correctly on your PC, then it means that everything is fine for continuing.
Logcat
Code:
adb logcat
It will display the real time log of your device
Best time to do it is when your device boots up
Now, many users ask me how to copy the logcat and upload it from CMD
There are several methods:-
1. Right click on the Title Bar of Command Prompt. Hover the cursor over edit and select mark. Select all the things you want to copy and then click enter. All the things will be copied to clipboard.
2. This is the correct way of getting logcat saved.
Code:
adb logcat > logcat.txt
This command will create a logcat.txt document in platform-tools folder with the complete logcat of the device. Ofcourse you can type any name instead of logcat.txt
3. I prefer taking logcat this way as it neatly compiles logs of different time
Code:
adb logcat -v long > logcat.txt
This is a very nice way to get logcat.
Installing Apps
Code:
adb install %PATH OF APK%
This will install an app on your Android
For example, if my app AreeB.apk is in G:\ drive (G:\AreeB.apk)
Then I will type
Code:
adb install G:\AreeB.apk
Be sure your apk is not in a folder that has space in its name, else the command will break at space bar.
For eg:-
G:\Program Files\AreeB.apk
Mounting
However, I never found any problem in tweaking with system files with adb, but some users said that they couldn't do it, so the problem was that their system partition was mounted as Read Only(R/O)
So, it is necessary now to tell how to mount system partition as Read Write(R/W)
Code:
adb remount
It is easiest way to do so, if it does not work then
There is another method that we will discuss in ADB Shell commands section
Pushing and Pulling
For pushing,
Type
Code:
adb push %PATH TO BE PUSHED% %PATH WHERE TO BE PUSHED%
Suppose I have an app named SystemUI.apk(PATH = G:\SystemUI.apk) which I want to push in /system/app/ on my android(or in other words, install an app as a system app). Then I would type
Code:
adb push G:\SystemUI.apk /system/app/
More examples
G:\Dance.txt file to be pushed in Dance folder in sdcard
Code:
adb push G:\Dance.txt /sdcard/Dance/
OR
Code:
adb push G:\Dance.txt /mnt/sdcard/Dance/
G:\Movies folder to be transferred in SDCARD in Videos Folder
Code:
adb push G:\Movies /sdcard/Videos/
G:\system\framework\framework-res.apk to be pushed in /system/framework/
Code:
adb push G:\system\framework\framework-res.apk /system/framework/
For pulling,
push command replaces with pull and paths are swapped
Code:
adb pull %PATH TO BE PULLED FROM% %PATH TO PLACE PULLED FILE%
Example,
All system apps are to be pulled to G:\ROM\system\app
Code:
adb pull /system/app G:\ROM\system\app\
build.prop to be extracted to desktop
Code:
adb pull /system/build.prop C:\Users\Areeb\Desktop\
However, if a folder is in platform-tools folder, you don't need to type full path
Suppose if I type
Code:
adb pull /system/ system
Then a folder named system will be created inside platform-tools with all the files in system in it
If a file is in platform-tools folder, then also no need to type full path
For example,
There is an app name DeskClock.apk in this folder then, to push it to /system/app, type
Code:
adb push DeskClock.apk /system/app/
ADB Shell Commands
This mode of adb allows you to execute linux shell commands from your PC
These commands can aldo be executed through the mobile using Terminal Emulator
To initiate shell mode
Type
Code:
adb shell
You will get an prompt like this
sh-3.2#
Now you are in shell mode
adb commands won't work here and a new set of commands will work here. But we will only go in a little detail here.
Assuming you are in adb shell mode, I will only type commands that will work on shell. Note:- These commands won't work if you type them alone on cmd. But, these command will directly work on your mobile's Terminal Emulator
As these commands can also work on mobile, I am going to tell you a way of taking logcat on mobile
Type
Code:
logcat
You will see log of your device
To save this
Type
Code:
logcat > /sdcard/log.txt
A file named log.txt will be generated in sdcard
Uninstalling Applications
Code:
cd /data/app
This will change the directory to /data/app
Code:
ls
This will show the list of files in there
Suppose, there is an app named com.opera.browser (Opera Mobile) you want to uninstall it
Type
Code:
rm -r com.opera.browser
This will uninstall the app
Mounting Command:-
Code:
mount -o rw,remount /dev/block/mtdblock3 /system
Miscellanous commands:-
su: Initiates root request
du: Shows file foldrs and size
date: Shows todays date
Forgot next ones, will write later
Credits
Google: For Android and several searchings
Samsung: For Galaxy Ace s5830I
Broadcom: For their Open Sourceness
XDA Forums : For the precious knowledge
My Uncle: For gifting me this Phone
My Teachers: For teaching me English(I would not be here without them)
You: For future Thanks
Till now, thats it, will add some more things later
If any problem, I will add it too
Suggestion? They are welcome

[GUIDE][ADB] How to take a logcat

iamareebjamal said:
ADB:-
Android Debug Bridge
Very useful program made itself by Google for Programmers and developers. Its based on command line and basically communicates with your Android to respond to certain commands. There is vast amount of knowledge about adb but its most useful commands limit to getting:-
Logcat:-
A real time log of what is happening in background of our devices. It is really useful for developers to see which component has malfunctioned and helps to narrow down their search for what failed and what needs to be fixed. Several times users are asked to give logcats of their devices which are giving errors. We will go in detail that how to get logcats in every and easiest way possible.
App Installation and Management:-
adb proves really handy if you want to install apks directly from your PC or want to batch install or delete them.
Shell Execution:-
You must have heard of Terminal Emulator. It is an app for android to execute shell commands(linux commands) which are basically present as applets in /system/bin, /system/sbin or /system/xbin(in our case) folders. A very imporant applet called busybox is installed there mainly used for execution of basic commands during root browsing or ROM installation. Many times updater script of ROMs use busybox commands to install it. Well, these commands can be initiated from your device too but they can be initiated from adb also making it easy for programmers.
Pushing and Pulling:-
Most used commands of adb. adb makes it a piece of cake for new device developers to get an ideo of structure and basic knowledge of devices by pulling command. We can pull out i.e copy any files or folders from our devices to our PC, even the root directories without rooting the devices. It help rooters and ROM chefs of new devices to get an idea and implement their mods on them. Pushing is also very useful command. It copies your files and folders from PC to your device. Very useful in pushing some /system apps and other things
Remounting and setting permissions
Basic commands:-
Of-course basic commands such as rebooting and rebooting in recovery mode and download mode are supported.
Others:-
There are several other features of adb such as fastboot, aapt, etc
Setting up ADB
Pre Requirements:-
A little amount of brain
PC(This is a windows guide, if asked I will add linux and mac guide later)
Java Runtime environment or Java Developing kit
Your Device Drivers
An Android Device
USB Debugging MUST be turned ON in the device for ADB to see it & Developer options is hidden in Android 4.2 and
above, Hitting Build number 10 times in
About Phone/Tablet reveals the menu (Thanks lilHermit for reminding me to add it)
Assuming you all these ready and working properly, we continue
If you are having trouble completing Pre-Requisites, there are several guides featuring them too
Start
1. First Download Android SDK. Roughly about 70 MB
2. There may be any compressed zip file or exe file
If zip file, then extract it to C:\android-sdk
If exe file then double click on it and install it in C:\ Drive(or any other drive you want)
3. Now to get adb and other tools, you need to download 'Platform Tools'
To download them, go to the android-sdk folder and double click on SDK Manager
It will ask you which package to download? However, it is your choice which package to Download, but here, we will only talk about platform
Tools. So, simply tick on Platform Tools and click on install. Once you have done it. Go to the platform-tools folder in the directory where you installed android-sdk. You will find several files there like adb, fastboot, aapt, etc
4. Now, you can backup the whole folder of android-sdk to any external storage that will make you not download package
again if you want to. You can have it placed in any computer and run it as it does not require registry to work
5. Now, you are just one step away from using adb. Next step is SKIPPING SETTING ENVIRONMENT VARIABLE (If you however want to set environment variables. Click on Show Content)
We can easily append the sdk platform-tools and tools folder to your systems environmental path variable directly from command line(cmd) by simply issuing one command and performing a system reboot:
Code:
SETX PATH "%PATH%;[COLOR="Indigo"]SDK_Install_Path[/COLOR]\platform-tools;[COLOR="Indigo"]SDK_Install_Path[/COLOR]\android-sdk-windows\tools" -m
Just replace the "SDK_Install_Path" in the above with the proper path of your SDK installation. Example: C:\android-sdk-windows
(Thanks to WugFresh for telling me :victory
Many guides on internet say that it is to be done for making it easy for users and if you have some basic knowledge of Command Prompt,
you will know that to execute any application with command prompt, you first need to change the directory to the one where application is
placed. And to skip changing the directories every time you open CMD, you need to put that application is environment variable. Howeve, we will not do so.
6. Type cmd in the search bar. Copy cmd.exe from there. Go to the directory where you have installed android-sdk. Go to platform-tools folder. Paste cmd there, right click on it and in the settings, select Run as Administrator.
7. You are done. Now what to do in it?
ADB Commands
Type adb in command prompt. And several commands will show up on your screen. It is very difficult to analyse these all commands, so we will only talk about most used and important commands
Connect your device via USB cable
And open the CMD in platform-tools folder(Make a shortcut of it on desktop). And type the suitable commands
Code:
adb devices
Will show the list of devices attached to the PC andtheir serial numbers. If this shows up correctly on your PC, then it means that everything is fine for continuing.
Logcat
Code:
adb logcat
It will display the real time log of your device
Best time to do it is when your device boots up
Now, many users ask me how to copy the logcat and upload it from CMD
There are several methods:-
1. Right click on the Title Bar of Command Prompt. Hover the cursor over edit and select mark. Select all the things you want to copy and then click enter. All the things will be copied to clipboard.
2. This is the correct way of getting logcat saved.
Code:
adb logcat > logcat.txt
This command will create a logcat.txt document in platform-tools folder with the complete logcat of the device. Ofcourse you can type any name instead of logcat.txt
3. I prefer taking logcat this way as it neatly compiles logs of different time
Code:
adb logcat -v long > logcat.txt
This is a very nice way to get logcat.
Installing Apps
Code:
adb install %PATH OF APK%
This will install an app on your Android
For example, if my app AreeB.apk is in G:\ drive (G:\AreeB.apk)
Then I will type
Code:
adb install G:\AreeB.apk
Be sure your apk is not in a folder that has space in its name, else the command will break at space bar.
For eg:-
G:\Program Files\AreeB.apk
Note:
If you have spaces in path of apk, you can execute the command without breakage if you include the path inside quotes. (Thanks to etcman)
Eg:-
Code:
adb install "G:\Program Files\AreeB.apk"
Mounting
However, I never found any problem in tweaking with system files with adb, but some users said that they couldn't do it, so the problem was that their system partition was mounted as Read Only(R/O)
So, it is necessary now to tell how to mount system partition as Read Write(R/W)
Code:
adb remount
It is easiest way to do so, if it does not work then
There is another method that we will discuss in ADB Shell commands section
Pushing and Pulling
For pushing,
Type
Code:
adb push %PATH TO BE PUSHED% %PATH WHERE TO BE PUSHED%
Suppose I have an app named SystemUI.apk(PATH = G:\SystemUI.apk) which I want to push in /system/app/ on my android(or in other words, install an app as a system app). Then I would type
Code:
adb push G:\SystemUI.apk /system/app/
More examples
G:\Dance.txt file to be pushed in Dance folder in sdcard
Code:
adb push G:\Dance.txt /sdcard/Dance/
OR
Code:
adb push G:\Dance.txt /mnt/sdcard/Dance/
G:\Movies folder to be transferred in SDCARD in Videos Folder
Code:
adb push G:\Movies /sdcard/Videos/
G:\system\framework\framework-res.apk to be pushed in /system/framework/
Code:
adb push G:\system\framework\framework-res.apk /system/framework/
For pulling,
push command replaces with pull and paths are swapped
Code:
adb pull %PATH TO BE PULLED FROM% %PATH TO PLACE PULLED FILE%
Example,
All system apps are to be pulled to G:\ROM\system\app
Code:
adb pull /system/app G:\ROM\system\app\
build.prop to be extracted to desktop
Code:
adb pull /system/build.prop C:\Users\Areeb\Desktop\
However, if a folder is in platform-tools folder, you don't need to type full path
Suppose if I type
Code:
adb pull /system/ system
Then a folder named system will be created inside platform-tools with all the files in system in it
If a file is in platform-tools folder, then also no need to type full path
For example,
There is an app name DeskClock.apk in this folder then, to push it to /system/app, type
Code:
adb push DeskClock.apk /system/app/
ADB Shell Commands
This mode of adb allows you to execute linux shell commands from your PC
These commands can aldo be executed through the mobile using Terminal Emulator
To initiate shell mode
Type
Code:
adb shell
You will get an prompt like this
sh-3.2#
Now you are in shell mode
adb commands won't work here and a new set of commands will work here. But we will only go in a little detail here.
Assuming you are in adb shell mode, I will only type commands that will work on shell. Note:- These commands won't work if you type them alone on cmd. But, these command will directly work on your mobile's Terminal Emulator
As these commands can also work on mobile, I am going to tell you a way of taking logcat on mobile
Type
Code:
logcat
You will see log of your device
To save this
Type
Code:
logcat > /sdcard/log.txt
A file named log.txt will be generated in sdcard
Uninstalling Applications
Code:
cd /data/app
This will change the directory to /data/app
Code:
ls
This will show the list of files in there
Suppose, there is an app named com.opera.browser (Opera Mobile) you want to uninstall it
Type
Code:
rm -r com.opera.browser
This will uninstall the app
Mounting Command:-
Code:
mount -o rw,remount /dev/block/mtdblock3 /system
Miscellanous commands:-
su: Initiates root request
du: Shows file foldrs and size
date: Shows todays date
ls: Shows list of directory
cd: Changes working directory
rm: Removes the file
logcat: Displays logcat
mount: Mounts the partition
busybox: Busybox Applets
Forgot next ones, will write later
Credits
Google: For Android and several searchings
Samsung: For Galaxy Ace s5830I
paxChristos for amazing logcat guide
Broadcom: For their Open Sourceness
XDA Forums : For the precious knowledge
My Uncle: For gifting me this Phone
My Teachers: For teaching me English(I would not be here without them)
You: For future Thanks
Till now, thats it, will add some more things later
If any problem, I will add it too
Suggestion? They are welcome
Click to expand...
Click to collapse
This should help the new members in appealing their problems in a deeper and better way.
Originally posted by iamareebjamal
Original thread here.

Categories

Resources