1.程序无响应,ANR问题:在日志中搜索“ANR”
2.崩溃问题:在日志中搜索“CRASH”
3.其他问题:在日志中搜索”Exception”
搜索了一下,发现无1,2问题,但又一个Exception异常
Got IOException performing flipjava.io.IOException: write failed: EINVAL (Invalid argument)
// Injection Failed
百度后,发现别人这样解释的:monkey发送各种事件操作app,中间有一个io异常,但是并没有堆栈,所以没有任何意义。
如果在这里发现monkey崩溃日志,应该要看monkey当时执行了什么事情,自己手动执行看看是否出现,如果不出现,再次使用相同的seed和相同的页面,再次启动app monkey再来一次随机测试,如果没有出现,证明次问题是偶然性问题。
3.adb logcat查看安卓日志
记得只查看并过滤自己操作的app日志,不过在屏幕上输出并不好找出问题,最好把它输出到text文件再查看
命令如下:
adb logcat -v time | findstr vchat.faceme >C:UsersadminDownloadsTESTERmonkey_logandriod_log.txt
一样的搜索关键字ANR/CRASH/Exception 查看日志异常
搜索到一个崩溃和一个异常:
08-13 11:09:27.658 D/CrashReport(15779): >>> vchat.faceme.ui.personal.PersonalSettingActivity onResumed <<<
08-12 20:12:20.073 D/Error ( 4763): ERR: stack=android.util.Log$TerribleFailure: {"ptid":"4763-1*","stack":"java.lang.NumberFormatException: Invalid long: "gp-500108"\n at java.lang.Long.invalidLong(Long.java:124)\n at java.lang.Long.parse(Long.java:363)\n at java.lang.Long.parseLong(Long.java:353)\n at java.lang.Long.parseLong(Long.java:321)\n at vchat.common.util.IMDecodeUtil.decodeContactByTargetId(IMDecodeUtil.java:96)\n at vchat.faceme.message.adapter.MessageListAdapter.convert(MessageListAdapter.java:65)\n at vchat.faceme.message.adapter.MessageListAdapter.convert(MessageListAdapter.java:47)\n at com.chad.library.adapter.base.BaseQuickAdapter.onBindViewHolder(BaseQuickAdapter.java:937)\n at com.chad.library.adapter.base.BaseQuickAdapter.onBindViewHolder(BaseQuickAdapter.java:66)\n at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6890)\n at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6932)\n at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5852)\n at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6119)\n at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5958)\n at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5954)\n at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2226)\n at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)\n at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)\n at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)\n at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3990)\n at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3402)\n at android.view.View.measure(View.java:18831)\n at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1248)\n at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1593)\n at android.view.View.measure(View.java:18831)\n at vchat.common.widget.MyDrawerLayout.onMeasure(MyDrawerLayout.java:1115)\n at android.view.View.measure(View.java:18831)\n at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1248)\n at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1593)\n at android.view.View.measure(View.java:18831)\n at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5990)\n at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)\n at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)\n at android.view.View.measure(View.java:18831)\n at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5990)\n at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)\n at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)\n at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)\n at android.view.View.measure(View.java:18831)\n at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5990)\n at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)\n at android.view.View.measure(View.java:18831)\n at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5990)\n at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)\n at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)\n at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)\n at android.view.View.measure(View.java:18831)\n at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5990)\n at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)\n at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:26
出现了一个崩溃异常,给开发反馈后,开发果然知道是出现了什么问题,然后正在看,对我来说,合适蛮有成就感的哈哈哈
停止monkey的办法:
注意 Monkey启动后会不断地向被测对象发送随机事件流,直到事件执行完毕或者发生异常时才停止。在Monkey运行过程中,即便断开 与PC的连接,Monkey依然可以在手机上继续运行。
停止Monkey的方法是:直接杀掉手机上的Monkey进程。具体方法如下:
adb shell 进入脚本界面
shell界面输入
ps |grep monkey
获取到com.android.commands.monkey的进程ID
kill pid进程号
使用monkey查看app是否有内存泄露:
adb shell monkey -p vchat.faceme --pct-touch 100 --throttle 1000 -s 100 -v -v 50 >C:UsersadminDownloadsTESTERmonkey_logjava_monkey_log.txt
adb shell 查看进程内存
dumpsys meminfo 后面有点难,后面再看好了