今天用红米手机搞自动化测试,用appium启动真机时,出现了以下错误
error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
具体错误日志截图如下
开始看到这个错误信息时我也不知道怎么办,后面通过通读日志发现了关键点:
java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=6785, uid=6785 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server
然后通过强大的百度功能,终于找到了有效的解决办法:
该问题出现的原因是:安装了不同的uiautomator版本,卸载原来的就行。
但是手动卸载Appium Settings后还是会出现该问题
需要在终点命令窗口中输入以下命令:
adb uninstall io.appium.uiautomator2.server.test
然后在通过appium启动就不会有问题了
解决方法参考了这篇博客https://www.jianshu.com/p/2662ec47415e