HOW TO USE ADB , DDMS & TAKING AN LOGCAT ..etc
WHAT IS ADB???
Whenever you create an android app or when you develop an Rom , it is important that you must deliver GOOD QUALITY APP or ROM , that are rid of Bugs ..Eventually you might come across a situation when your APP or ROM isn't working or it is bricking the device or some things are not working .These situation can be tackled only with a proper debugging tools ..So ADB ( android debug bridge) is a powerful Debugging tool and a tool which allows us to step through each line of code and examine the value of each variable.It offers us some of the powerful tools ..Debugging is not a big deal for the people who come from a JAVA programming background .Dalvik VM in android supports java debug wire protocol to attach to the device over ADBQuote:
ADB or ANDROID DEBUG BRIDGE is a command-line utility that is often used to communicate over the debug channel with a connected phone or virtual device (emulator). ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more...
Even if you already have the Java runtime (JRE) installed, you’ll need to install the JDK as well.
After installing Java JDK , you can now download the Android SDK from Google .
NOTE:- If you see a any type of Java-related error during installation, then download and install the x86 version of the JDK, not the x64 one ..
After clicking on "DOWNLOAD FOR OTHER PLATFORMS" , you will get an extended menu ..
After downloading the .exe file , then Double click on the .exe file and install it in C:\ Drive or on whichever drive you wanna install .
3) Android SDK Setup
Enable the Android SDK tools and SDK Platform-tools checkbox and click the Install button. This downloads and installs the platform-tools package, which contains ADB and other utilities.
After installing these packages , Go to the place where you installed ANDROID SDK . IN MY CASE , IT IS :-
Browse to platform tools and hold Shift and right-click inside it, and select Open command window here...
NOW YOU WILL SEE THIS :-
1) you must enable USB debugging on it. You’ll find this option under Developer Options on your device’s Settings screen
2)You must install your device drivers :- Individual OEM USB drivers for windows are available for each manufacturer and are listed in the official document ..
After you have downloaded you device drivers, then we have to install on our pc. for that :-
b) right click on MY COMPUTER and click manage
c) go to devices > other devices and right click on device and select update driver software.
d) you should see an option to " BROWSE MY COMPUTER FOR DRIVER SOFTWARE" , which you nedd to click on and point to the location of your device driver installation file..
To test whether ADB is working properly, connect your Android device to your computer using a USB cable and run the following command:
Now you have sucessfully installed ADB and now we are good to go further..
Logcat is the command to view the internal logs of the Android system. Viewing logs is often the best way to diagnose a problem, and is required for many issues. This way you'll find out what apps are doing in the background without you noticing.
Now type this in the terminal
adb logcat -v long > logcat.txt
Code: adb logcat > logcat.txt
SOME OF THE USEFULL ADB COMMANDS :-
adb install C:\package.apk
EG -adb install G:\xda.apk
adb uninstall package.name
EG :- you’d use the name com.quoordy.xdadevelopers to uninstall the Xda developers app.
adb push C:\file /sdcard/file
EG :-adb push G:\system\framework\framework-res.apk /system/framework
adb pull /sdcard/file C:\file
adb shell command
When you guys are experimenting on a custom rom (i.e. nightlies, betas, RC's, "just cooked", etc.), it's very likely that your phone might not boot correctly, fear not and instead, try using ADB there are loads of guides regarding how to properly set-up your PC for using ADB, starting by the Android SDK's page itself :P lol
Now, to do the said logcat, open a command window and do:
C:\Users\Dark> cd \\sdk\platform-tools [Hit ENTER!]
C:\\sdk\plarform-tools> adb.exe devices (just to make sure your computer detected your phone lol)
C:\\sdk\plarform-tools> adb.exe logcat -v long > somefile.txt (the "-v long" part creates a nicely formatted file )
That's it!! Remember to zip the file if it's too big
Another tip: Some phones are very catchy when under heavy issues (like mine ) in those cases, timing is essential between rebooting and getting your log, however!!! The adb logcat command makes sure to wait for the device to get detected