android的adb介绍,Android开发基础不牢

ok

后,模拟器有如下反应:

(3)    sms测试

sms send 13522543026 hello

ok

则, 在模拟器的messaging中,就会看到有一条短信了.

如图:

13    ddms.bat

===============================================================================

3.1   直接启动ddms


E:/android_sdk/android-sdk-windows-1.6_r1/tools>ddms

02:30 I/ddms: Created: [Debugger 8600–>568 inactive]

02:30 I/ddms: Created: [Debugger 8601–>617 inactive]

02:30 I/ddms: Created: [Debugger 8602–>619 inactive]

02:30 I/ddms: Created: [Debugger 8603–>657 inactive]

02:30 I/ddms: Created: [Debugger 8604–>670 inactive]

02:30 I/ddms: Created: [Debugger 8605–>681 inactive]

这和eclipse中的ddms是一样的.

4     adb

======================================================================

1.14.1        Adb help:


直接运行adb会显示出adb的help信息.如下:

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb -help

Android Debug Bridge version 1.0.22

-d                            - directs command to the only connected USB device

returns an error if more than one USB device is present.

-e                            - directs command to the only running emulator.

returns an error if more than one emulator is running.

-s             - directs command to the USB device or emulator with

the given serial number

-p      - simple product name like ‘sooner’, or

a relative/absolute path to a product

out directory like ‘out/target/product/sooner’.

If -p is not specified, the ANDROID_PRODUCT_OUT

environment variable is used, which must

be an absolute path.

devices                       - list all connected devices

device commands:

adb push     - copy file/dir to device

adb pull     - copy file/dir from device

adb sync [ ]     - copy host->device only if changed

(see ‘adb help all’)

adb shell                    - run remote shell interactively

adb shell           - run remote shell command

adb emu             - run emulator console command

adb logcat [ ] - View device log

adb forward - forward socket connections

forward specs are one of:

tcp:

localabstract:

localreserved:

localfilesystem:

dev:

jdwp: (remote only)

adb jdwp                     - list PIDs of processes hosting a JDWP transport

adb install [-l] [-r] - push this package file to the device and install it

(’-l’ means forward-lock the app)

(’-r’ means reinstall the app, keeping its data)

adb uninstall [-k] - remove this app package from the device

(’-k’ means keep the data and cache directories)

adb bugreport                - return all information from the device

that should be included in a bug report.

adb help                     - show this help message

adb version                  - show version num

DATAOPTS:

(no option)                   - don’t touch the data partition

-w                           - wipe the data partition

-d                           - flash the data partition

scripting:

adb wait-for-device          - block until device is online

adb start-server             - ensure that there is a server running

adb kill-server              - kill the server if it is running

adb get-state                - prints: offline | bootloader | device

adb get-serialno             - prints:

adb status-window            - continuously print device status for a specified device

adb remount                  - remounts the /system partition on the device read-write

adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program

adb root                     - restarts adb with root permissions

networking:

adb ppp [parameters]   - Run PPP over USB.

Note: you should not automatically start a PPP connection.

refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1

[parameters] - Eg. defaultroute debug dump local notty usepeerdns

adb sync notes: adb sync [ ]

can be interpreted in several ways:

  • If is not specified, both /system and /data partitions will be updated.

-          If it is “system” or “data”, only the corresponding partition

is updated.

14.2        scripting:



(1) start adb server

方法1: E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb kill-server

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb start-server

* daemon not running. starting it now *

* daemon started successfully *

E:/android_sdk/android-sdk-windows-1.6_r1/tools>

方法2: E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb kill-server

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb fork-server server

OK

注意: 方法1是直接用adb的scripting “adb start-server” 来启动的, 启动成功后,直接返回到cmd命令窗口;

方法2 是用直接启动adb server进程的方式” adb fork-server server”来启动的,启动成功后, 显示”OK”, 并且不返回到cmd命令窗口.

分析: 这是因为adb.exe是一个命令(可执行程序), 它启动后,会调用到” adb fork-server server”(这个server正是adb server), 然后, adb.exe就退出了,这时,只剩下adb server 这个进程了,这个进程的名字也是adb.exe.而方法2是直接启动adb server,所以,不能退出,如果退出,就相当于adb server退出了.

adb server启动后,会在任务管理器中进程中可以看到adb.exe.

如果用户将adb.exe 强行结束了,那么, 对于方法2,就会回到cmd窗口.

另外,如果eclipse中启动了模拟器,那么, 强行结束adb server后, 会再启动一个.

(2) adb get-state and get-serialno

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb get-state

device

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb get-serialno

emulator-5554

如果同时启动了两个模拟器,则这两个脚本的执行结果均是:

unknown

(3) adb root

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb root

adbd is already running as root

adb reboot recovery

(4) adb reboot [android-sdk-windows-1.6_r1支持]

adb reboot bootloader(或 recovery)

说明:reboots the device, optionally into the bootloader or recovery program,可见,只针对真机,

所以,当运行此脚本时,模拟器就不能运行了。

另外,此脚本是从android-sdk-windows-1.6_r1开始支持的。

1.12.3        device commands:


(1) list all connected devices

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb devices

List of devices attached

emulator-5554   device

emulator-5556   device

(2) adb shell

开机:

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb shell

ls

ls

sqlite_stmt_journals

cache

sdcard

etc

system

sys

sbin

proc

init.rc

init.goldfish.rc

init

default.prop

data

root

dev

cd data

cd data

ls

ls

misc

local

data

app-private

app

property

anr

dalvik-cache

system

lost+found

cd data

cd data

pwd

pwd

/data/data

ls -l

Ls -l

ls -l

ls -l

drwxr-xr-x app_0    app_0             2009-11-25 02:42 com.android.packageinstaller

drwxr-xr-x app_1    app_1             2009-11-25 02:42 com.android.providers.contacts

drwxr-xr-x app_2    app_2             2009-11-25 02:42 com.android.fallback

drwxr-xr-x app_1    app_1             2009-11-25 02:42 com.android.inputmethod.latin

drwxr-xr-x app_3    app_3             2009-11-25 02:42 com.android.gesture.builder

drwxr-xr-x app_4    app_4             2009-11-25 02:42 com.google.android.marvin.talkback

drwxr-xr-x app_5    app_5             2009-11-25 02:42 com.android.providers.downloads

drwxr-xr-x app_1    app_1             2009-11-25 02:42 com.android.inputmethod.pinyin

drwxr-xr-x system   system            2009-11-25 02:42 com.android.providers.settings

drwxr-xr-x app_6    app_6             2009-11-25 02:42 com.android.development

drwxr-xr-x app_7    app_7             2009-11-25 02:42 com.android.email

drwxr-xr-x app_8    app_8             2009-11-25 02:42 com.android.music

drwxr-xr-x app_1    app_1             2009-11-25 02:42 com.android.globalsearch

drwxr-xr-x app_9    app_9             2009-11-25 02:42 jp.co.omronsoft.openwnn

drwxr-xr-x app_10   app_10            2009-11-25 02:42 com.android.mms

drwxr-xr-x app_5    app_5             2009-11-25 02:42 com.android.camera

drwxr-xr-x app_11   app_11            2009-11-25 02:42 com.android.term

drwxr-xr-x system   system            2009-11-25 02:42 com.android.settings

drwxr-xr-x app_12   app_12            2009-11-25 02:42 com.android.browser

drwxr-xr-x app_13   app_13            2009-11-25 02:42 android.tts

drwxr-xr-x app_14   app_14            2009-11-25 02:42 com.android.customlocale

drwxr-xr-x app_1    app_1             2009-11-25 02:42 com.android.providers.userdictionary

drwxr-xr-x app_15   app_15            2009-11-25 02:42 com.android.soundrecorder

drwxr-xr-x app_16   app_16            2009-11-25 02:42 com.android.netspeed

drwxr-xr-x radio    radio             2009-11-25 02:43 com.android.phone

drwxr-xr-x app_1    app_1             2009-11-25 02:43 com.android.contacts

drwxr-xr-x app_17   app_17            2009-11-25 02:43 com.android.htmlviewer

drwxr-xr-x system   system            2009-11-25 02:43 com.android.server.vpn

drwxr-xr-x app_1    app_1             2009-11-25 02:43 com.google.android.providers.enhancedgooglesearch

drwxr-xr-x app_18   app_18            2009-11-25 02:43 com.android.sdksetup

drwxr-xr-x app_4    app_4             2009-11-25 02:43 com.google.android.marvin.soundback

drwxr-xr-x app_5    app_5             2009-11-25 02:43 com.android.providers.drm

drwxr-xr-x app_1    app_1             2009-11-25 02:43 com.android.launcher

drwxr-xr-x app_1    app_1             2009-11-25 02:43 com.android.providers.applications

drwxr-xr-x app_19   app_19            2009-11-25 02:43 com.svox.pico

drwxr-xr-x app_5    app_5             2009-11-25 02:43 com.android.providers.media

drwxr-xr-x app_20   app_20            2009-11-25 02:43 com.android.calculator2

drwxr-xr-x app_4    app_4             2009-11-25 02:43 com.google.android.marvin.kickback

drwxr-xr-x radio    radio             2009-11-25 02:43 com.android.providers.telephony

drwxr-xr-x app_21   app_21            2009-11-25 02:43 com.android.alarmclock

drwxr-xr-x app_22   app_22            2009-11-25 02:43 com.android.spare_parts

先后启动kx011和a两个应用程序(都是activity),则,

在/data/data下,就会看到如下两个应用了,

ls

a.a

com.kx011

而且,在/data/app下,也有这两个应用的apk文件。

cd /data/app

cd /data/app

ls

ls

com.kx011.apk

a.a.apk

说明:在/data/data目录下,存放了所有系统已经启动的的应用程序;

在/data/app下,以apk的形式存放了用户建立的应用。

(3)adb pull      // 说明:copy file/dir from device

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb pull /init.rc F:/ABD/x.txt

668 KB/s (10700 bytes in 0.015s)

adb push     - copy file/dir to device

adb pull     - copy file/dir from device

(4)adb push  // 说明:copy file/dir to device

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb push ddms.bat /data/

124 KB/s (1992 bytes in 0.015s)

(5) adb install

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb install D:/allProject/android16/kx011/bin/kx011.apk

259 KB/s (8297 bytes in 0.031s)

pkg: /data/local/tmp/kx011.apk

Success

说明: install 完成之后,直接进入adb shell

(6) adb jdwp

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb jdwp

567

614

616

641

661

678

707

714

(7) adb bugreport

列出了bug信息,see to bugreport.txt    [ 点击查看 ]

13    关于编译

=======================================================================

1.13.1        am:

结语

看到这篇文章的人不知道有多少是和我一样的Android程序员。

35岁,这是我们这个行业普遍的失业高发阶段,这种情况下如果还不提升自己的技能,进阶发展,我想,很可能就是本行业的职业生涯的终点了。

我们要有危机意识,切莫等到一切都成定局时才开始追悔莫及。只要有规划的,有系统地学习,进阶提升自己并不难,给自己多充一点电,你才能走的更远。

千里之行始于足下。这是上小学时,那种一元钱一个的日记本上每一页下面都印刷有的一句话,当时只觉得这句话很短,后来渐渐长大才慢慢明白这句话的真正的含义。

有了学习的想法就赶快行动起来吧,不要被其他的事情牵绊住了前行的脚步。不要等到裁员时才开始担忧,不要等到面试前一晚才开始紧张,不要等到35岁甚至更晚才开始想起来要学习要进阶。

给大家一份系统的Android学习进阶资料,希望这份资料可以给大家提供帮助。

droid-sdk-windows-1.6_r1/tools>adb install D:/allProject/android16/kx011/bin/kx011.apk

259 KB/s (8297 bytes in 0.031s)

pkg: /data/local/tmp/kx011.apk

Success

说明: install 完成之后,直接进入adb shell

(6) adb jdwp

E:/android_sdk/android-sdk-windows-1.6_r1/tools>adb jdwp

567

614

616

641

661

678

707

714

(7) adb bugreport

列出了bug信息,see to bugreport.txt    [ 点击查看 ]

13    关于编译

=======================================================================

1.13.1        am:

结语

看到这篇文章的人不知道有多少是和我一样的Android程序员。

35岁,这是我们这个行业普遍的失业高发阶段,这种情况下如果还不提升自己的技能,进阶发展,我想,很可能就是本行业的职业生涯的终点了。

我们要有危机意识,切莫等到一切都成定局时才开始追悔莫及。只要有规划的,有系统地学习,进阶提升自己并不难,给自己多充一点电,你才能走的更远。

千里之行始于足下。这是上小学时,那种一元钱一个的日记本上每一页下面都印刷有的一句话,当时只觉得这句话很短,后来渐渐长大才慢慢明白这句话的真正的含义。

有了学习的想法就赶快行动起来吧,不要被其他的事情牵绊住了前行的脚步。不要等到裁员时才开始担忧,不要等到面试前一晚才开始紧张,不要等到35岁甚至更晚才开始想起来要学习要进阶。

给大家一份系统的Android学习进阶资料,希望这份资料可以给大家提供帮助。
[外链图片转存中…(img-ve0yVpZS-1647757985603)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值