adb常用命令及遇到的问题总结

转载请注明出处:http://blog.csdn.net/zhangyang0402/article/details/13095637

一、常用adb命令

1.查看设备  
$ adb devices
List of devices attached
emulator-5554   device
6651084d70b674  device

2. 连接特定设备
-d  连接的device,只能有一个,否则会报错
-e  连接的模拟器,只能有一个,否则报错
-s  指定特定的设备或模拟器

3. 进入设备的shell
$ adb -d shell
$ adb -e shell

4. 安装/卸载apk
$ adb -e install ~/Downloads/apk/_b_9.5.101.apk
2658 KB/s (3803627 bytes in 1.397s)
    pkg: /data/local/tmp/_b_9.5.101.apk
Success


卸载应用程序
$ adb uninstall  app_name

安装的应用程序在/data/data/目录下,可在目录下直接查看app_name,或通过下面的方法。

app_name是在AndroidManifest.xml中<manifest>节点下,package元素所指定的名字
将原来apk解压得到的AndroidManifest.xml,打开是乱码,需要使用apktool反编译得到AndroidManifest.xml,才能打开正常看。


$ apktool d ~/Downloads/apk/_b_9.5.101.apk
在当前目录下得到_b_9.5.101目录

查找app安装好后的名字
$ cat _b_9.5.101/AndroidManifest.xml |grep manifest
<manifest android:versionCode="1101" android:versionName="9.5.101" android:installLocation="auto" package="cn.chinabus.main"
</manifest>


$ adb uninstall cn.chinabus.main
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Success

5. 传输文件(push/pull)
$ adb pull /init.rc ~/Downloads/
533 KB/s (24001 bytes in 0.043s)

$ adb push ~/Downloads/adb_usb.ini  /data
0 KB/s (7 bytes in 0.062s)


6. logcat
If you want to control the format of each log entry is dumped, you need to use the "adb logcat -v <format>" option, which supports the following formats:

    "adb logcat -v brief" - Display priority/tag and the PID of process issuing the message (the default format).
    "adb logcat -v process" - Display PID only.
    "adb logcat -v tag" - Display the priority/tag only.
    "adb logcat -v raw" - Display the raw log message, with no other metadata fields.
    "adb logcat -v time" - Display the date, invocation time, priority/tag, and PID of the process issuing the message.
    "adb logcat -v thread" - Display the priority, tag, and the PID and TID of the thread issuing the message.
    "adb logcat -v threadtime" - Display the date, invocation time, priority, tag, and the PID and TID of the thread issuing the message.
    "adb logcat -v long" - Display all metadata fields and separate messages with a blank lines.

一般使用这个参数
adb logcat -v threadtime &

7. 端口转发
$ adb forward tcp:port tcp:port
在使用gdb或ARM DS-5, host和target需要进行通讯时,要设置这个,否则无法正常通信。


adb 常见问题
1. adb devices no permissions

$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
????????????    no permissions

$ adb shell
error: insufficient permissions for device

解决方法:
$ sudo adb kill-server
$ sudo adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
19761202    device

2. adb push时失败, Read-only file system

$ adb -d push ../../out/target/product/generic/system/bin/myloop  /system/bin
failed to copy '../../out/target/product/generic/system/bin/myloop' to '/system/bin/myloop': Read-only file system

解决方法1:
$ adb root

$ adb remount
remount succeeded

$ adb -d push ../../out/target/product/generic/system/bin/myloop  /system/bin
101 KB/s (5504 bytes in 0.052s)

解决方法2:
$ adb shell
# su
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# chmod 777 /system
# exit


  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用adb命令在设备上创建txt文件,可以按照以下步骤进行操作: 1. 首先,确保你已经连接上了设备,并且adb已经正确安装和配置。 2. 打开命令行终端或者命令提示符窗口。 3. 输入以下命令来创建txt文件: adb shell touch /sdcard/filename.txt 这个命令会在设备的sdcard目录下创建一个名为filename.txt的txt文件。 4. 如果你想在其他目录下创建txt文件,可以将路径修改为你想要创建文件的路径。 请注意,如果你在创建文件时遇到权限问题,可能需要使用su命令来获取root权限。具体的命令可以根据你的设备和系统版本而有所不同。 希望这个回答对你有帮助!\[1\] #### 引用[.reference_title] - *1* [android studio 使用adb命令传递文件到android设备](https://blog.csdn.net/weixin_42332131/article/details/116727622)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [常用adb命令](https://blog.csdn.net/fcjjlj/article/details/128084889)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [adb文件管理命令操作实例讲解](https://blog.csdn.net/weixin_30831261/article/details/116214283)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值