Difference between revisions of "Android Debug Bridge - adb shell guide"

From thelinuxwiki
Jump to: navigation, search
(backup a particular app / apk)
 
(4 intermediate revisions by one user not shown)
Line 28: Line 28:
 
at this point you are connected to your device.  You can move around the phone file system, list files, etc..
 
at this point you are connected to your device.  You can move around the phone file system, list files, etc..
  
'''copy files off the device'''
+
copy files off the device
 
   $ adb pull /pathtofileondevice localfilename
 
   $ adb pull /pathtofileondevice localfilename
 
'''
 
'''
Line 34: Line 34:
 
   $ adb push localfilename /pathtofileondevice
 
   $ adb push localfilename /pathtofileondevice
  
 +
backup a device
 +
 +
I attempted the below procedure but the backup would hang at the shared storage (sdcard).
 +
 +
$adb backup -shared -all -f my_backup_file
 +
Now unlock your device and confirm the backup operation.
 +
 +
You will be promped on screed at the device to confirm the backup by selecting "Back up my data".  You can also choose to encrypt the backup file and lock it with a password.  (android 4.2.2)
 +
 +
==backup a particular app / apk==
 +
 +
list phone packages
 +
adb shell pm list packages [options] filter
 +
 +
usage options: -3: Filter to only show third party packages, -f: See their associated file
 +
example
 +
$ '''adb shell pm list packages -f -3 abccorp_app'''
 +
package:/data/app/com.abccorp.abccorp_app-fww9oZOScSyUhl26nLwn6g==/base.apk=com.abccorp.abccorp
 +
 +
pull apk from phone
 +
$ '''adb pull <filename on device> <local filename>'''
 +
 +
$ '''adb pull /data/app/com.abccorp.abccorp_app-fww9oZOScSyUhl26nLwn6g==/base.apk abccorp_app_1.1.1'''
 +
/data/app/com.abccorp.abccorp_app-fww9oZOScSyUhl26nLwn6g==/base.apk: 1 file pulled. 13.9 MB/s (29403087 bytes in 2.014s)
 +
 +
where filename is the string provided by the package list up to .apk
 +
 +
and
 +
 +
where abccorp_app_1.1.1 is the filename of your choosing. I get the app version from the android gui on the device apps list. I don't know of a way to get it from adb.
 +
 +
==links==
 
[http://developer.android.com/tools/help/adb.html Full Android Debug Bridge reference at android.com]
 
[http://developer.android.com/tools/help/adb.html Full Android Debug Bridge reference at android.com]
  
  
 
[[category:android]]
 
[[category:android]]

Latest revision as of 18:35, 19 February 2022

Android Debug Bridge

connecting to a physical phone using adb

enable developer usb debugging

go to and enable: Settings > Applications > Development > USB debugging

enabling app installation

go to and enable: Settings > Applications > Unknown sources


command line

The adb command line utility is installed as part of the Android SDK

list locally attached devices

$ adb devices
List of devices attached 
c7b5b844        device

run shell interactively

$ adb shell
shell@android:/ $ 

at this point you are connected to your device. You can move around the phone file system, list files, etc..

copy files off the device

 $ adb pull /pathtofileondevice localfilename

copy files to the device

 $ adb push localfilename /pathtofileondevice

backup a device

I attempted the below procedure but the backup would hang at the shared storage (sdcard).

$adb backup -shared -all -f my_backup_file
Now unlock your device and confirm the backup operation.

You will be promped on screed at the device to confirm the backup by selecting "Back up my data". You can also choose to encrypt the backup file and lock it with a password. (android 4.2.2)

backup a particular app / apk

list phone packages

adb shell pm list packages [options] filter

usage options: -3: Filter to only show third party packages, -f: See their associated file example

$ adb shell pm list packages -f -3 abccorp_app
package:/data/app/com.abccorp.abccorp_app-fww9oZOScSyUhl26nLwn6g==/base.apk=com.abccorp.abccorp

pull apk from phone

$ adb pull <filename on device> <local filename>
$ adb pull /data/app/com.abccorp.abccorp_app-fww9oZOScSyUhl26nLwn6g==/base.apk abccorp_app_1.1.1
/data/app/com.abccorp.abccorp_app-fww9oZOScSyUhl26nLwn6g==/base.apk: 1 file pulled. 13.9 MB/s (29403087 bytes in 2.014s)

where filename is the string provided by the package list up to .apk

and

where abccorp_app_1.1.1 is the filename of your choosing. I get the app version from the android gui on the device apps list. I don't know of a way to get it from adb.

links

Full Android Debug Bridge reference at android.com