New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
xlm13x
Old
(Last edited by xlm13x; 18th November 2012 at 03:53 PM.)
#1  
xlm13x's Avatar
Recognized Contributor - OP
Thanks Meter 651
Posts: 1,529
Join Date: Mar 2012
Location: XDA 24 X 7
Default [WINDOWS][TUT]ADB tutorial, setting up ADB, usefull commands, collecting debug info.

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
Attached Files
File Type: zip ADB.zip - [Click for QR Code] (652.7 KB, 1484 views)
I HAVE ORD

ADB Tutorial.
Unbrick Galaxy-R





>>> PORN!!! <<<

Get 500 mb free on dropbox by signing up HERE, i will also get same
 


The Following 21 Users Say Thank You to xlm13x For This Useful Post: [ Click to Expand ]
 
xlm13x
Old
(Last edited by xlm13x; 30th July 2012 at 09:47 AM.) Reason: added logcats on mobile
#2  
xlm13x's Avatar
Recognized Contributor - OP
Thanks Meter 651
Posts: 1,529
Join Date: Mar 2012
Location: XDA 24 X 7
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.
I HAVE ORD

ADB Tutorial.
Unbrick Galaxy-R





>>> PORN!!! <<<

Get 500 mb free on dropbox by signing up HERE, i will also get same
 


The Following 11 Users Say Thank You to xlm13x For This Useful Post: [ Click to Expand ]
 
xlm13x
Old
(Last edited by xlm13x; 12th July 2012 at 01:48 PM.)
#3  
xlm13x's Avatar
Recognized Contributor - OP
Thanks Meter 651
Posts: 1,529
Join Date: Mar 2012
Location: XDA 24 X 7
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"
I HAVE ORD

ADB Tutorial.
Unbrick Galaxy-R





>>> PORN!!! <<<

Get 500 mb free on dropbox by signing up HERE, i will also get same
 


The Following 11 Users Say Thank You to xlm13x For This Useful Post: [ Click to Expand ]
 
JoJo2012
Old
(Last edited by JoJo2012; 15th July 2012 at 01:43 PM.)
#4  
Member
Thanks Meter 7
Posts: 36
Join Date: Jun 2012
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
 
CallMeVentus
Old
#5  
CallMeVentus's Avatar
Recognized Contributor
Thanks Meter 2661
Posts: 9,312
Join Date: Jul 2011
Location: Singapore
Quote:
Originally Posted by JoJo2012 View Post
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
If you have enabled USB Debugging , yes

"I have to go. It's just....they really need me." - Sora
TeamCooper:
www.teamcooper.net



GitHub:
Personal: www.github.com/EmoBoiix3
CyanMobile: www.github.com/CyanMobile
TeamFun (a.k.a GingerDX): www.github.com/TeamFun

Read this if you are new to your Galaxy Ace





"My friends are my power, and I'm theirs!"
"I am the boy with the heart of pure light."
 
12manytimes
Old
#6  
Senior Member
Thanks Meter 22
Posts: 129
Join Date: Aug 2010
Location: San Francisco

 
DONATE TO ME
Default 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!!!!!
 
Adam77Root
Old
#7  
Adam77Root's Avatar
Recognized Developer
Thanks Meter 7319
Posts: 1,188
Join Date: Jul 2012
Location: My coordinates
Quote:
Originally Posted by 12manytimes View Post
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!!!!!
'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
The Following 2 Users Say Thank You to Adam77Root For This Useful Post: [ Click to Expand ]
 
12manytimes
Old
#8  
Senior Member
Thanks Meter 22
Posts: 129
Join Date: Aug 2010
Location: San Francisco

 
DONATE TO ME
Quote:
Originally Posted by Adam77Root View Post
'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
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
 
12manytimes
Old
#9  
Senior Member
Thanks Meter 22
Posts: 129
Join Date: Aug 2010
Location: San Francisco

 
DONATE TO ME
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