Android 常用命令行和 源码编译

1.取出 ANR log,分析问题
C:\Users\Administrator>adb shell
root@android:/ # cd data/ar
cd data/ar
/system/bin/sh: cd: /data/ar - No such file or directory
1|root@android:/ # cd data/anr
cd data/anr
root@android:/data/anr # ls
ls
traces.txt
导出traces.txt即可
C:\Users\Administrator>adb pull /data/anr/traces.txt  d:/
140 KB/s (56265 bytes in 0.390s)
导入:
C:\Users\Administrator>adb push dd.png  /sdcard/

2.日志过滤,根据pid
adb connect 
adb shelll
ps
adb logcat | busybox grep pid
3.删除系统应用
C:\Users\Administrator>adb shell
$ su   //付权限
su
# cd data/app  //第三方
cd data/app
# ls
ls
slideCount
com.wandoujia.phoenix2.usbproxy-2.apk
com.soufun.app-1.apk
com.noshufou.android.su-1.apk
com.sina.weibo-1.apk
sina.mobile.tianqitong-2.apk
net.sunniwell.app.swdmc-2.apk
com.wandoujia.phoenix2-1.apk
rm -rf  com.sina.weibo-1.apk  //删除apk
4.连接和断开远程终端
adb connect 192.168.5.220
adb disconnect 192.168.5.220
5.查看日志
查看多个TAG的日志
C:\Users\Administrator>adb logcat -s lixp:* li:*
查看一个TAG的日志
C:\Users\Administrator>adb logcat -s lixp:* 
//清理日志
C:\Users\Administrator>adb logcat -c
adb logcat -v time  //显示日志时间
adb logcat > c:\123.txt
6.用cygwin编so库
Administrator@lixp-PC ~
$ cd e:
//进入项目中lib所在目录
Administrator@lixp-PC /cygdrive/e
$ cd E:/svn_depository/Projector
Administrator@lixp-PC /cygdrive/e/svn_depository/Projector
//执行下面这行命令
$ $NDK/ndk-build
Cygwin         : Generating dependency file converter script
Compile thumb  : Httpdjni <= com_ysten_istouch_jni_httpd_HttpNative.c
jni/com_ysten_istouch_jni_httpd_HttpNative.c: In function 'Java_com_ysten_istouch_jni_httpd_HttpNative_startHttpd':
jni/com_ysten_istouch_jni_httpd_HttpNative.c:63: warning: assignment from incompatible pointer type
jni/com_ysten_istouch_jni_httpd_HttpNative.c:74: warning: incompatible implicit declaration of built-in function 'sprintf'
jni/com_ysten_istouch_jni_httpd_HttpNative.c:75: warning: passing argument 1 of 'mg_set_option' from incompatible pointer type
jni/Mongoose.h:103: note: expected 'struct mg_context *' but argument is of type 'struct mg_context1 *'
jni/com_ysten_istouch_jni_httpd_HttpNative.c:76: warning: passing argument 1 of 'mg_set_option' from incompatible pointer type
jni/Mongoose.h:103: note: expected 'struct mg_context *' but argument is of type 'struct mg_context1 *'
jni/com_ysten_istouch_jni_httpd_HttpNative.c:81: warning: passing argument 1 of 'mg_get_option' from incompatible pointer type
jni/Mongoose.h:88: note: expected 'const struct mg_context *' but argument is of type 'struct mg_context1 *'
jni/com_ysten_istouch_jni_httpd_HttpNative.c:82: warning: passing argument 1 of 'mg_get_option' from incompatible pointer type
jni/Mongoose.h:88: note: expected 'const struct mg_context *' but argument is of type 'struct mg_context1 *'
Compile thumb  : Httpdjni <= Mongoose.c
SharedLibrary  : libHttpdjni.so
Install        : libHttpdjni.so => libs/armeabi/libHttpdjni.so
Administrator@lixp-PC /cygdrive/e/svn_depository/Projector
7.查找手机内存中的数据库
C:\Users\Administrator>adb shell
$ su
su

# cd data
cd data
# ls
ls
com.tencent.mm
com.sec.android.app.selftestmode
com.adobe.flashplayer
com.gameloft.android.GAND.GloftA
# cd com.test
cd com.test
# ls
ls
lib
databases
# cd databases
cd databases
# ls
ls
mycity.db
#
这就找到了,应该需要root权限;
8.用命令行操作按键
C:\Users\Administrator>adb devices
List of devices attached
emulator-5554   device
C:\Users\Administrator>adb shell
root@android:/ #
root@android:/ # input
input
usage: input ...
       input text <string>
       input keyevent <key code number or name>
       input [touchscreen|touchpad] tap <x> <y>
       input [touchscreen|touchpad] swipe <x1> <y1> <x2> <
       input trackball press
       input trackball roll <dx> <dy>
root@android:/ # input keyevent 22
input keyevent 22
root@android:/ # input keyevent 22
input keyevent 22
root@android:/ # input keyevent 23
input keyevent 23
root@android:/ #
C:\Users\Administrator>
9.查看md5值
在cygwin里面用md5sum + apk路径; 查看应用的md5值
C:\Users\Administrator>adb kill-server
C:\Users\Administrator>adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
10.找不到R文件,很多与xml布局里面用到的包名有关,也要改掉!
11.删除系统apk
//先将只读的文件设置能够删除
C:\Users\lixp>adb remount
remount succeeded
tools>adb shell
#su
#cd system/sd/data //进入系统内指定文件夹
#ls //列表显示当前文件夹内容
#rm -r xxx //删除名字为xxx的文件夹及其里面的所有文件
#rm xxx //删除文件xxx
#rmdir xxx //删除xxx的文件夹
12. cat      ps     busybox     grep
C:\Users\Administrator>adb push C:\Users\Administrator\Desktop\DeviceInfo.ini /system/etc/ini
1 KB/s (345 bytes in 0.204s)
C:\Users\Administrator>adb shell
root@android:/ # cat /etc/ini/DeviceInfo.ini   //一次显示所有文件
cat /etc/ini/DeviceInfo.ini
[DEVICE]
ItvManageBackupServer=http://tmsyst.is.ysten.net:8080/yst-tms
ItvManageServerIp=tmsyst.is.ysten.com
TermType=
QRCode=
PlatformType=
PlatformId=00000021201305021525593
NoticeInterval=600
Boot=http://bimsboot.ysten.com:9144/yst-bims-facade/stb/bootstrap.xml
BootIp=http://58.214.17.67:9144/yst-bims-facade/stb/bootstrap.xml
root@android:/ # ps | busybox grep Yst    //搜索和看进程
ps | busybox grep Yst
root      81    1     100576 97032 ffffffff 400cfc94 S /system/bin/YstLoginSrv
root      82    1     7904   1760  ffffffff 4000ec94 S /system/bin/YstCdnManager
root      83    1     5244   1184  ffffffff 400edc94 S /system/bin/YstQOSASS
root@android:/ # kill -9 81
kill -9 81
ps: 显示瞬间行程 (process) 的动态;
grep: Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来;
cat : 1.一次显示整个文件。          $ cat   filename
2.从键盘创建一个文件。              $ cat  >  filename   只能创建新文件,不能编辑已有文件.
3.将几个文件合并为一个文件。  $cat   file1   file2  > file
13.源码编译:
1).进入到源码目录下;
2).输入命令:
 #soure build/envsetup.sh
 #lunch 13 (即 apollo_newmi-eng)
3)进入到代码目录执行命令:#mm -B(重新编译)
14通过adb工具查看手机ip信息,可以通过netcfg命令。简单介绍两种具体方式:
1、进入adb目录,直接输入:adb shell netcfg
2、进入adb shell,输入netcfg
只adb中执行命令时,也许会提示你权限不够,这个时候用su ,提升为root哦!
15.开启应用
C:\Users\Administrator>adb  shell  am  start  -n  com.touch.server.window/.SetWindow
Starting: Intent { cmp=com.touch.server.window/.SetWindow }
16.查看进程
adb shell kill PIDNumber :死你想杀死的后台进程来模拟某种 bug 的复现条件。
adb shell ps :查看当前终端中的进程信息
pm install -r /storage/emulated/0/ysten/update/PublishPanel.apk  //强制安装-----------------------

root@ysten-e4-gw:/data/app # pm uninstall com.istv.launcher
pm uninstall com.istv.launcher
Success
17. money命令
18.用类型转换运算符 运算符形式是这样的 (类型),注意数值太大容易丢精度
例如 int a=5;
float b=(float)a ;
19 top 命令
adb shell top命令
执行Linux下的top、ps等命令,这些命令你也通过adb可以执行查看效果。
adb shell
$ top -h
top -h
Usage: top [-m max_procs] [-n iterations] [-d delay] [-s sort_column] [-t] [-h]
  -m num Maximum number of processes to display. // 最多显示多少个进程
 -n num Updates to show before exiting. // 刷新次数
 -d num Seconds to wait between updates. // 刷新间隔时间(默认5秒)
 -s col Column to sort by <cpu,vss,rss,thr> // 按哪列排序
 -t   Show threads instead of processes. // 显示线程信息而不是进程
 -h   Display this help screen. // 显示帮助文档
$ top -n 1
top -n 1
User 35%, System 13%, IOW 0%, IRQ 0% // CPU占用率
User 109 + Nice 0 + Sys 40 + Idle 156 + IOW 0 + IRQ 0 + SIRQ 1 = 306 // CPU使用情况
PID CPU% S #THR VSS RSS PCY UID Name // 进程属性
xx xx% x  xx xx xx xx xx  xx
CPU占用率:
User   用户进程
System 系统进程
IOW IO等待时间
IRQ 硬中断时间
CPU使用情况(指一个最小时间片内所占时间,单位jiffies。或者指所占进程数):
User   处于用户态的运行时间,不包含优先值为负进程
Nice  优先值为负的进程所占用的CPU时间
Sys 处于核心态的运行时间
Idle  除IO等待时间以外的其它等待时间
IOW IO等待时间
IRQ 硬中断时间
SIRQ  软中断时间
进程属性:
PID 进程在系统中的ID
20. 删除一个目录下所有的文件
root@ysten-e4-gw:/data/data/com.istv.launcher/files # busybox rm -fr *
busybox rm -fr *
21.重启adb server进程
adb kill-server  
adb start-server 
22.每秒更新,筛选tag
1|shell@cancro:/ $ top -d 1 | grep mediaserver
top -d 1 | grep mediaserver
23.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值