adb命令中似乎没有直接通过报名来过滤的功能,但是可以通过过滤进程的pid来过滤该应用的日志
过滤条件:该app在运行
实现原理:
1、获取该app运行时的pid
2、通过find命令,过滤pid的日志,就是该包的运行日志
实现:
1、在同一目录建立一文件:getpid.bat
@echo off adb shell "ps | grep com.example.testprogram"
复制以上代码,保存
2、在同一目录建立另外一个问文件:getpid1.bat
@echo off for /f "tokens=2 delims= " %%i in ('getpid.bat') do set pid=%%i echo %pid% adb logcat | find "%pid%" pause
复制以上代码,并保存
链接手机,启动com.example.testprogram这个app
双击getpid1.bat即可获取该程序的日志:
D/dalvikvm( 9017): Late-enabling CheckJNI I/ActivityManager( 2272): Start proc com.example.testprogram for activity com.example.testprogram/.MainActivity: pid=9017 uid=10070 gids={50070, 1028} D/libEGL ( 9017): loaded /system/lib/egl/libEGL_mali.so D/libEGL ( 9017): loaded /system/lib/egl/libGLESv1_CM_mali.so D/libEGL ( 9017): loaded /system/lib/egl/libGLESv2_mali.so E/ ( 9017): Device driver API match E/ ( 9017): Device driver API version: 17 E/ ( 9017): User space API version: 17 E/ ( 9017): mali: REVISION=Linux-r3p1-01rel1 BUILD_DATE=Tue Jul 2 15:06:24 KST 2013 D/OpenGLRenderer( 9017): Enabling debug mode 0 D/tag ( 9017): it's a log ! D/AndroidRuntime( 9017): Shutting down VM W/dalvikvm( 9017): threadid=1: thread exiting with uncaught exception (group=0x418dc700) E/AndroidRuntime( 9017): FATAL EXCEPTION: main E/AndroidRuntime( 9017): java.lang.ArithmeticException: divide by zero E/AndroidRuntime( 9017): at com.example.testprogram.MainActivity$2.onClick(MainActivity.java:33) E/AndroidRuntime( 9017): at android.view.View.performClick(View.java:4247) E/AndroidRuntime( 9017): at android.view.View$PerformClick.run(View.java:17728) E/AndroidRuntime( 9017): at android.os.Handler.handleCallback(Handler.java:730) E/AndroidRuntime( 9017): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime( 9017): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 9017): at android.app.ActivityThread.main(ActivityThread.java:5289) E/AndroidRuntime( 9017): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 9017): at java.lang.reflect.Method.invoke(Method.java:525) E/AndroidRuntime( 9017): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) E/AndroidRuntime( 9017): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) E/AndroidRuntime( 9017): at dalvik.system.NativeStart.main(Native Method) I/Process ( 9017): Sending signal. PID: 9017 SIG: 9 I/ActivityManager( 2272): Process com.example.testprogram (pid 9017) has died. W/InputMethodManagerService( 2272): Got RemoteException sending setActive(false) notification to pid 9017 uid 10070
时间: 2024-10-14 20:59:50