5,606,297 Members 32,098 Now Online
XDA Developers Android and Mobile Development Forum

GUIDES & FAQs [Android]: ADB Workshop by Adrynalyne and Guide by Captainkrtek

Tip us?
 
nir36
Old
(Last edited by timmymarsh; 23rd December 2010 at 02:34 PM.)
#1  
nir36's Avatar
Retired Moderator - OP
Thanks Meter 274
Posts: 3,845
Join Date: Dec 2007
Location: Jerusalem
Default GUIDES & FAQs [Android]: ADB Workshop by Adrynalyne and Guide by Captainkrtek

DO NOT POST IN THIS THREAD BEFORE READING THE WHOLE POST
PLEASE ADD GUIDES TO COMMON ISSUES YOURSELVES

To my recollection, the previous WM Guides thread was successful.. so we'll be moving on to android as well - from beginner to pro.

I hope this thread will provide answers to a decent percentage of your questions.

Please hold until guide collecting is finished..
In the meanwhile you are ALL invited to send me links or full guides to add to this thread.. remember, we are all about sharing.


COMING SOON! (in the meanwhile, you've got a great battery life guide at http://forum.xda-developers.com/showthread.php?t=471521 - be sure to thank BruceElliot for it!)

also, if you decide to post a guide, please keep the guide as neat as possible, with a title containing the LEVEL ([BEGINNER], [INTERMEDIATE], [PRO]) and the commonly searched words so that people who look for it can find it easily. (if you can, use the same color (dark orange) and same size (4) and Bold.. for the main title.. tho that's not a must )



post #2. [BEGINNERS+INTERMEDIATE] Replacing System Files using Android Commander
post #3. [EVERYONE] ADB Workshop by Adrynalyne and Guide by Captainkrtek
post #4. [QUICK FAQ's] Common QnA's for beginners by Timmymarsh (work in progress)

The Following 18 Users Say Thank You to nir36 For This Useful Post: [ Click to Expand ]
 
nir36
Old
(Last edited by nir36; 16th December 2010 at 12:26 AM.)
#2  
nir36's Avatar
Retired Moderator - OP
Thanks Meter 274
Posts: 3,845
Join Date: Dec 2007
Location: Jerusalem
Default [BEGINNERS] Replacing system files using Android Commander

Replacing system files using Android Commander:

(This post was formally based in the HD2's RTL support thread and revolved around our need to replace frameworks)

so:

1. Download the android SDK from: http://dl.google.com/android/android...08-windows.zip

2. EXTRACT(!!!) the android-sdk-windows to c:\
(make sure you extract the dir - not run the setup from inside the zip file)

3. install Android Commander from http://androidcommander.com

4. Connect your device and make sure it's set to Debugging mode in /settings/applications/development/

5. You might have to set a dir containing your adb.exe file. set it to c:\android-sdk-windows\tools\

6. You will see a Total Commander-like interface. you can then copy the framework.jar file to the correct directory (there's no difference between SD android builds and androids in ROM - the system dir will be shown the same way)

a. Yes, you can replace/delete system files while android is running.
b. (for androids running from SD) Any file copied to /sdcard/android/root/system/X will be copied to /system/X in the system file. The sdcard/android root dir is JUST LIKE your root in ROM androids.
c. Make sure you either created a backup or verified a match in any other way before replacing files like frameworks, zimage, modules, etc.. your android might not boot afterwards (I keep all system.ext2 files backed up so that i can restore them incase i screw something up.)

enjoy
The Following 15 Users Say Thank You to nir36 For This Useful Post: [ Click to Expand ]
 
nir36
Old
(Last edited by nir36; 21st December 2010 at 12:22 PM.)
#3  
nir36's Avatar
Retired Moderator - OP
Thanks Meter 274
Posts: 3,845
Join Date: Dec 2007
Location: Jerusalem
Default [EVERYONE] ADB Workshop by Adrynalyne and Guide by Captainkrtek

This following guide was rewritten by Captainkrtek, please make sure to thank him for it

Original Post:
(http://forum.xda-developers.com/showthread.php?t=879701)

This workshop was held in #android-learning on irc.freenode.net by XDA Member Adrynalyne. All credit to him for this guide
, I simply am taking it and turning it into a guide. Here we go!

You can find the raw IRC log here

Good evening folks, and welcome to my ADB workshop. This is by no means a full explanation on the subject, but more of a crash course to help folks get up to speed, and get more from their devices. There may be some things you already know here, so please be patient and respect those who do not.

Reference Files

http://adrynalyne.us/files/How%20to%20install%20adb.pdf
http://adrynalyne.us/files/Using%20ADB.pdf

So, lets just start with the basics.

What is ADB?
ADB stands for the android debugging bridge and is used for testing and debugging purposes by developers.

However, we like to get more out of our devices, and its a great way to fix things.
Knowing adb can mean the difference between a paperweight and a working phone.

So, to start with, we will look at installing ADB.
Generally speaking, the Sun/Oracle JDK is required to run all SDK functions.
ADB is but one tool in the SDK arsenal.
So, we begin by downloading and installing the JDK. This can be found here:

https://cds.sun.com/is-bin/INTERSHOP...-CDS_Developer

Choose your OS, download and install. I recommend that 64 bit users use the regular x86/32 bit version as well.
Moving ahead, we download the Windows sdk from here:

http://dl.google.com/android/installer_r08-windows.exe

Due to already installing JDK, you won't be stopped by the install process.
Now, if you notice, I installed it to:

C:\android-sdk-windows

I did this because it makes things easier when setting up path variables.
I encourage everyone to do the same, but obviously it is not required.

So, this SDK is handy, but is only good up to 2.2. We want the latest and greatest! (Well I do)

So, we navigate to:

C:\android-sdk-windows\

and we run SDK Manager.exe

If you notice in your PDF file for installing adb, you will notice that you can update, and I made a choice not to include earlier sdk versions.

I won't go into full detail on that, but depending on the version of SDK you have, 8 or 9, it WILL make a difference in using adb.
By default, for version 8 adb.exe resides in C:\android-sdk-windows\tools
By default, for version 9 adb.exe resides in C:\android-sdk-windows\platform-tools
We will assume version 9 in this guide

Really, the SDK is installed and adb is usable right now, but in my humble opinion, its not enough

I like the ability to use adb in ANY directory on my machine.
To do this, we edit Windows's environment variables.
Specifically, the system path.

To do this, we click on start, or the orb (depending on OS), and right click on Computer, left clicking on properties in the menu.
If its windows XP, I believe it brings you into advanced system properties immediatly. Vista and 7 need a second step.
On the left hand side, as you notice I have highlighted in the pdf, left click advanced system settings.

Under advanced tab, we left click environment variables...
There are two boxes here.
We are concerned with system variables, however.
So we scroll down the list and highlight path and click edit.
Ignoring all the extra stuff in here, make sure you are at the end of the line, and type

Code:
;C:\android-sdk-windows\platform-tools
The semicolon allows us to separate it

from the previous path statement.
Click ok all the way out.
We now have ADB setup globally. We can use cmd.exe (I use powershell) and no matter what directory we are in, adb is recognized.
If it is not, make certain you entered the path into system variables, and made no typos.
If you installed to a different location, you will need to adjust the path accordingly.

This concludes the section on installing the Android SDK to use ADB.

This next section will be on using ADB, so please open that pdf now.
Now, this applies to any OS, not just Windows.
Well, with the exception of the USB drivers.
I will not go too much into that, but if you take a look at the PDF, it goes through installing usb drivers for the sdk, and how to download them.
Fiarly straightforward, in that rspect.

Now, to setup our phones to use with the SDK and ADB, we must change some settings.
First, we go to menu softkey, then settings.
We scroll down to Applications and tap it.
Under Development, we will check Enable USB Debugging. Please note the SGS phones are different in this respect.
The USB cable must be unplugged before enabling or disabling this setting.
Once this is done, we are now ready to play with adb

One quick note: If you get device not found/conencted, please reboot your phone. DJ05 has a quirk in it where ADBD randomly crashes on boot.
A reboot will fix this


ADBD= ADB Daemon

Ok, continuing on.
Lets look at installing applications. This is also known as sideloading.
Unlike installing from the SD card, it does not require unknown sources to be enabled.
The command for this is

Code:
adb install packagename
This assumes that you are working from the directory where the file is located.
This will install the application to /data/app.
It will also show sometimes useful errors if install fails.
That is not something you will see from the Android GUI.
Now, a lot of us have probably deleted files with apps like Root Explorer. While this isn't really a bad thing, it leaves behind databases and data for the application removed.
This is where the 0kb applicaiton entries come from.
If you take that application entry name, you can uninstall the extra data via adb.
First we go to the adb shell which logs into the phone.

Code:
adb shell
If we end up with a $, we will want admin rights, in many cases. This is not one of them, I don't beleive.
To get admin rights, you want to type

Code:
su
Look at your phone if this is the first time, it may prompt you to allow access. Else you will get permission denied.
If you are not rooted, this will not work either.
Ok, now that we are logged in, we will type

Code:
pm uninstall packagename
where packagename is the name of the 0kb listing.

Now this seems like a pain in the a** and I agree.
HOWEVER
There will be a time where Manage applications crashes when you try to uninstall it from the phone. In this case, a factory reset, or this method is the only effective way to fix the problem.
Moving on.
How many of us have removed system applications or renamed them? Did you know that you can simply disable them from the system?

Code:
adb shell
su
pm disable appllicationname
This will disable it, and the system will ignore it.
This can be seen as safer than deleting or renaming things, but your mileage may vary.
On the other hand, you can also re-enable these applications.

Code:
adb shell
su
pm enable applicationname
Please note: Not all applications will properly re-enable. I believe a factory reset or reinstall of said application will fix the issue.
Also, application names are absolutely case sensitive.

*nix based Operating Systems see the letter 'a' and 'A' as two different things.
when you log into adb shell, you are playing by android rules


Ok, a lot of us tweak and mod our phones and turning off the device to get to clockwork recovery, or battery pulls, or multiple button holds to get into Download mode are troublesome and annoying at best.
ADB can help us here.
Here, we do not need to be logged into the shell
If we want to merely reboot the phone:
Code:
adb reboot
If we want to go to recovery (works well with voodoo5)
Code:
adb reboot recovery
If we want to go to Download Mode because we need Odin, heaven forbid:
Code:
adb reboot download
Its instant. No waiting on animations or anything else.
Its also handy if Android has locked up, but yet still works in adb.
I for one hate taking my case off to battery pull.

So now we move on to pushing and pulling files.
Sometimes, I don't feel like mounting my sd card to copy a file over to my phone.
I can use this command to push a file straight to my sd card:
Code:
adb push filename /pathtodirectoryonphone
So for instance, if I have test.txt that I want to send, I would type:

Code:
adb push test.txt /sdcard/
and there it goes.
Ok moving on
Pushing files can be done to any directory, however, some are protected.
For instance, /system is going to give you a permission denied or a read only filesystem error.
To get around this, the easiest thing to do is push the file to your sdcard, then log into the shell:
Code:
adb shell
Code:
su
We will then mount the system as writable
Code:
mount -o rw,remount /dev/block/stl9 /system
Then we can use something like
Code:
cp /sdcard/test.txt /system/app/test.txt
cp stands for copy
and it requires the path of the file and destination path. The name of the file is optional
When you copy it, you can rename it to whatever you like.
For instance, if we wanted to backup a file
Code:
cp /sdcard/test.txt /sdcard/backuptest.txt
Now, lets assume you do not have busybox installed.
You non rooted users will not.
Then you must use a slightly more complicated command called dd
This is used like this:

Code:
dd if=/sdcard/test.txt of=/system/app/test.txt
if is for inputfile
of= output file

Not every user friendly, but probably one of the safer copy commands.

Ok, moving on to pulling files.
Lets say you want to get a file from your phone, to modify, backup, etc.
To do this, we simply use adb in this manner:
Code:
adb pull /pathtofile/filename destinationname
For instance, if I wanted to backup ADW launcher in system/app
I would do this

Code:
adb pull /system/app/ADWLaucnher.apk ADWLauncher.apk
And it will pull the file from the phone and put it in the current directory.
Like above, you can specifcy where it goes.

pushing files to the sdcard, it seems prudent to talk about changing permissions.
sdcards are typically fat32, which destroys permisisons, and Android is heavily permission based.
So if you push an application to your sd card, then try to copy it to /system/app/ bad things are going to happen, or the app may not even show up.

So in that case, we use something called chmod.
This is used in this manner
Code:
adb shell
su
chmod 755 /pathtoapplication/applicationname
Keep in mind
you dont want to do this while its still on your sd card.
an example
Code:
adb shell
su
chmod 755 /system/app/ADWLauncher.apk
755 is good for applications and script files.

Just a couple more topics to cover.
Lets go over deleting files.
This becomes especially handy for removing rogue applications.
To do this, we must be in the adb shell.

Code:
adb shell
su
rm /system/app/ADWLauncher.apk
You may need to remount system as writable with:

Code:
mount -o rw,remount /dev/block/stl9 /system
That applies when using chmod as well.
So what I did above was delete ADW Launcher from system/app
However, what if I wanted to delete the entire contents of a directory?
Same thing as before, except
Code:
adb shell
rm -f /data/dalvik-cache/*.*
I just cleared my dalvik-cache with that command

very quick, very effective.

If you just tried that, please reboot your phone now

Ok....this leaves us with the final topic: logcat
logcat allows us to log what the OS is doing, and possibly delve information for when things are not working
its quite simple Reading it is another.
To use logcat

Code:
adb shell
logcat
To logcat to a certain file do

Code:
adb shell
logcat > /sdcard/logcat.txt
Now we let the log settle down to a reasonable amount of data coming in and not a wall of scrolling, then start the app in question. When it gives an error, we hit ctrl-C and kill the adb shell session.

This should have captured enough data to see the error. Now, I prepared an example. A user came to me on IRC, and Google Maps was force closing. Clearing data didnt fix it, Clearing dalvik-cache, and fix permissions did not fix it. In this case, the user did not know how to use adb So I had him grab an app called alogcat from the market and email me the log. This is also a very valid method.
this file explains what the problem was, and highlights what to look for as an example.

http://adrynalyne.us/files/logcat.pdf
__________________________________________________ _________________
This concludes the guide from Adrynalyne, there will be more workshops such as this one in irc.freenode.net #android-learning.
Thanks to everyone in #samsung-fascinate !
The Following 27 Users Say Thank You to nir36 For This Useful Post: [ Click to Expand ]
 
timmymarsh
Old
(Last edited by timmymarsh; 27th December 2010 at 05:06 PM.)
#4  
timmymarsh's Avatar
Developer Committee / Senior Moderator - Just one more
Thanks Meter 995
Posts: 4,997
Join Date: Mar 2007
Location: Jersey, UK. Likes: Witch hunts. Dislikes: ibones

 
DONATE TO ME
QUICK FAQ's
sources: Q&A Section, The Weekly Q&A Section by XDA News Writers (thanks guys)



  • Q: ‘Is there any way to block specific apps from using my data connection?’
  • A: Try the Droid Wall application.
  • Q: ‘I read how you can make changes in the build.prop file on my Android device. How exactly do I get to it?’
  • A: Install ASTRO file manager, browse to /system, long press on build.prop – Edit – Copy. Press on the home icon then Edit icon – Paste. Connect sd card, edit it, and paste it over from where you copied build.prop
  • Q: What happens if I update my phone? will I need to re-root it and get the ROM again? will all of my applications get erased? If so, is there a way around this?
  • A: You will lose your root, but not apps if it is just an update.
  • Q: I just tried to flash a ROM from recovery on my Android phone and got “Verification Failed, Installation Aborted” What happened?
  • A: Before you can flash a custom ROM the .zip file must be digitally signed in the ROM kitchen, if unzipped and re-zipped it will lose its verification, this happens often using the Safari browser as it likes to decompress .zip’s. Or if your download is corrupted (download the ROM again) it will fail the Verification.
  • Q - HTC Location Widget shows "map data unavailable"
  • A - On the widget, click the pin/then click the windows button/click get more/scroll to download maps/download relevant map (care, maybe a big file). Now exit and click onto map, your location should now be visible :)
  • Q:So, I moved all the apps on the SD, but is still not enough. How can I free some memory? I could delete the cache of the older upgrade or something else?
  • A:Do you have pictures and videos? If so, check if they are on the SD card and not on your internal memory. Cleaning your cache helps, and try deleting your text messages threads.
  • Q: ‘What exactly is a kernel and what are the benefits in changing it?’
  • A: A kernel is a bridge between the applications and the actual data processing done at the hardware level. The kernel’s responsibilities include managing the system’s resources – the communication between hardware and software components. Flashing different kernels gives you different operating speeds, better battery life, the ability to overclock, and more.
The Following 21 Users Say Thank You to timmymarsh For This Useful Post: [ Click to Expand ]
 
fongwe
Old
(Last edited by fongwe; 29th October 2011 at 01:33 PM.)
#5  
Member
Thanks Meter 10
Posts: 51
Join Date: Oct 2011
Location: Chiang mai
Android control other device with IOIO Board.
It use ADB.


http://androidcontrol.blogspot.com/2011/10/ioio-board-for-android-control-io.html
The Following User Says Thank You to fongwe For This Useful Post: [ Click to Expand ]
 
gh198x
Old
#6  
gh198x's Avatar
Junior Member
Thanks Meter 3
Posts: 2
Join Date: Aug 2011
Location: Los Angeles
Quote:
Originally Posted by timmymarsh View Post
QUICK FAQ's
sources: Q&A Section, The Weekly Q&A Section by XDA News Writers (thanks guys)



  • Q: ‘Is there any way to block specific apps from using my data connection?’
  • A: Try the Droid Wall application.
  • Q: ‘I read how you can make changes in the build.prop file on my Android device. How exactly do I get to it?’
  • A: Install ASTRO file manager, browse to /system, long press on build.prop – Edit – Copy. Press on the home icon then Edit icon – Paste. Connect sd card, edit it, and paste it over from where you copied build.prop
  • Q: What happens if I update my phone? will I need to re-root it and get the ROM again? will all of my applications get erased? If so, is there a way around this?
  • A: You will lose your root, but not apps if it is just an update.
  • Q: I just tried to flash a ROM from recovery on my Android phone and got “Verification Failed, Installation Aborted” What happened?
  • A: Before you can flash a custom ROM the .zip file must be digitally signed in the ROM kitchen, if unzipped and re-zipped it will lose its verification, this happens often using the Safari browser as it likes to decompress .zip’s. Or if your download is corrupted (download the ROM again) it will fail the Verification.
  • Q - HTC Location Widget shows "map data unavailable"
  • A - On the widget, click the pin/then click the windows button/click get more/scroll to download maps/download relevant map (care, maybe a big file). Now exit and click onto map, your location should now be visible :)
  • Q:So, I moved all the apps on the SD, but is still not enough. How can I free some memory? I could delete the cache of the older upgrade or something else?
  • A:Do you have pictures and videos? If so, check if they are on the SD card and not on your internal memory. Cleaning your cache helps, and try deleting your text messages threads.
  • Q: ‘What exactly is a kernel and what are the benefits in changing it?’
  • A: A kernel is a bridge between the applications and the actual data processing done at the hardware level. The kernel’s responsibilities include managing the system’s resources – the communication between hardware and software components. Flashing different kernels gives you different operating speeds, better battery life, the ability to overclock, and more.
Thank you for your patience and taking the time to answer those questions. I loved your simple and easily digestible format.
The Following 3 Users Say Thank You to gh198x For This Useful Post: [ Click to Expand ]
 
AdamOutler
Old
#7  
AdamOutler's Avatar
Recognized Developer
Thanks Meter 9432
Posts: 5,126
Join Date: Feb 2011
Location: Louisiana

 
DONATE TO ME
There is a note

Quote:
*nix based Operating Systems see the letter 'a' and 'A' as two different things.
when you log into adb shell, you are playing by android rules
this note is all wrong..

1. linNUX is not *NIX.
2. Mac OS-X is a *NIX OS, it is based upon UNIX, they use their own variant called Darwin. Darwin does not require capitolization.
3. The word should be POSIX. Linux is POSIX compliant and POSIX defines the capitolization standardards
Flash with Odin on Windows, Linux and Mac. Use JOdin3, Available in a web browser or offline
Check out my developer pages. Add me to your circles on Google Plus.
 
momskhatri
Old
#8  
Junior Member
Thanks Meter 6
Posts: 20
Join Date: Feb 2011
Location: Mumbai
Default soft brick

Quote:
Originally Posted by Taioba View Post
Is there any way to use ADB even though I can not enable USB debugging by the android?

I have an Atrix with soft-brick. How can I restore a file (framework-res.apk) knowing that my USB debugging is off?
I can enable ADB via fastboot?

Thanks!
I found this for atrix 4g....
http://forum.xda-developers.com/showthread.php?t=965546
hope it helps
 
knoknot
Old
#9  
Member
Thanks Meter 4
Posts: 37
Join Date: Jan 2012
Location: Nairobi
i have a bricked s2 not so sure how to go about reviving it via adb
 
Saki3d
Old
#10  
Saki3d's Avatar
Senior Member
Thanks Meter 276
Posts: 126
Join Date: Sep 2012
Quote:
Originally Posted by knoknot View Post
i have a bricked s2 not so sure how to go about reviving it via adb

check this thread
http://forum.xda-developers.com/show....php?t=1237815

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes