【Appium踩坑】A new session could not be created. UiAutomation not connected

1、解决办法1-粗暴版

(1)重启手机,100%解决
(2)插拔usb线 -> 针对使用atx的情况下

2、解决办法2-提高程序优先级

参考:
https://github.com/android/testing-samples/issues/89
在这里插入图片描述

3、原因

test program was killed by the android system, causing Uiautomator to not run normally.

4、详细报错信息


2021-12-08 10:40:30:778 - [debug] [W3C] Encountered internal error running command: A new session could not be created. Details: java.lang.IllegalStateException: UiAutomation not connected, UiAutomation@fc29743[id=-1, flags=0]
2021-12-08 10:40:30:779 - [debug] [W3C] io.appium.uiautomator2.common.exceptions.SessionNotCreatedException: java.lang.IllegalStateException: UiAutomation not connected, UiAutomation@fc29743[id=-1, flags=0]
2021-12-08 10:40:30:779 - [debug] [W3C] 	at io.appium.uiautomator2.handler.NewSession.safeHandle(NewSession.java:59)
2021-12-08 10:40:30:779 - [debug] [W3C] 	at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)
2021-12-08 10:40:30:779 - [debug] [W3C] 	at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)
2021-12-08 10:40:30:779 - [debug] [W3C] 	at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)
2021-12-08 10:40:30:779 - [debug] [W3C] 	at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:51)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2021-12-08 10:40:30:780 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2021-12-08 10:40:30:781 - [debug] [W3C] 	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
2021-12-08 10:40:30:781 - [debug] [W3C] 	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
2021-12-08 10:40:30:781 - [debug] [W3C] 	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
2021-12-08 10:40:30:781 - [debug] [W3C] 	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
2021-12-08 10:40:30:781 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
2021-12-08 10:40:30:782 - [debug] [W3C] 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
2021-12-08 10:40:30:783 - [debug] [W3C] 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
2021-12-08 10:40:30:783 - [debug] [W3C] 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
2021-12-08 10:40:30:783 - [debug] [W3C] 	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
2021-12-08 10:40:30:783 - [debug] [W3C] 	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
2021-12-08 10:40:30:783 - [debug] [W3C] 	at java.lang.Thread.run(Thread.java:923)
2021-12-08 10:40:30:783 - [debug] [W3C] Caused by: java.lang.IllegalStateException: UiAutomation not connected, UiAutomation@fc29743[id=-1, flags=0]
2021-12-08 10:40:30:784 - [debug] [W3C] 	at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1239)
2021-12-08 10:40:30:784 - [debug] [W3C] 	at android.app.UiAutomation.getServiceInfo(UiAutomation.java:497)
2021-12-08 10:40:30:784 - [debug] [W3C] 	at androidx.test.uiautomator.UiDevice.<init>(UiDevice.java:115)
2021-12-08 10:40:30:784 - [debug] [W3C] 	at androidx.test.uiautomator.UiDevice.getInstance(UiDevice.java:261)
2021-12-08 10:40:30:784 - [debug] [W3C] 	at io.appium.uiautomator2.utils.Device.getUiDevice(Device.java:25)
2021-12-08 10:40:30:784 - [debug] [W3C] 	at io.appium.uiautomator2.core.UiAutomatorBridge.getUiAutomation(UiAutomatorBridge.java:52)
2021-12-08 10:40:30:784 - [debug] [W3C] 	at io.appium.uiautomator2.core.UiAutomation.<init>(UiAutomation.java:32)
2021-12-08 10:40:30:785 - [debug] [W3C] 	at io.appium.uiautomator2.core.UiAutomation.getInstance(UiAutomation.java:37)
2021-12-08 10:40:30:785 - [debug] [W3C] 	at io.appium.uiautomator2.model.NotificationListener.<init>(NotificationListener.java:42)
2021-12-08 10:40:30:785 - [debug] [W3C] 	at io.appium.uiautomator2.model.NotificationListener.getInstance(NotificationListener.java:47)
2021-12-08 10:40:30:785 - [debug] [W3C] 	at io.appium.uiautomator2.handler.NewSession.safeHandle(NewSession.java:52)
2021-12-08 10:40:30:785 - [debug] [W3C] 	... 30 more
2021-12-08 10:40:30:785 - [debug] [W3C]
2021-12-08 10:40:30:791 - [HTTP] <-- POST /wd/hub/session 500 2048 ms - 4453
2021-12-08 10:40:30:791 - [HTTP]
2021-12-08 10:40:30:919 - [debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值