Long Press is not working with uiautomator2 - Appium 1.6

I am using:
Appium 1.6
Android - Samsung Galaxy 6 Edge - 6.0.1
uiautomator2

When the test gets to the code:

private void longPressByXpath() {
    WebElement myElement = driver.findElement(By.xpath("//*[contains(@text, 'Sign in to your Account')]"));
    TouchAction action = new TouchAction(driver);
    action.longPress(myElement).release().perform();
}

I will get the error:
FAILED: simpleTest(“android”)
io.appium.java_client.NoSuchContextException: org.json.JSONException: No value for elementId

[MJSONWP] Calling AppiumDriver.findElement() with args: [“xpath”,"//*[contains(@tex
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 0 ms for condition
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/285b175b-a798-47e6-bf55-4a41201b7ef0/element] with body: {“strategy”:“xpath”,"select…
[JSONWP Proxy] Got response with status 200: {“sessionId”:"285b175b-a798…
[MJSONWP] Responding to client with driver.findElement() result: {“ELEMENT”:"f0446c4a-c1d4-4…
[HTTP] <-- POST /wd/hub/session/d33767c1-5a17-4904-be59-e0ebbb517c34/element 200 114 ms - 122
[HTTP] --> POST /wd/hub/session/d33767c1-5a17-4904-be59-e0ebbb517c34/touch/perform {“actions”:[{“action”:“longPress”,“options”:{“element”:“f0446c4a-c1d4-42e8-88ca-448ea529c7dd”}},{“action”:“release”,“options”:{}}]}
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“longPress”,"op…
[UiAutomator2] calling get location: f0446c4a-c1d4-42e8-88ca-448ea529c7dd
[JSONWP Proxy] Proxying [GET /element/f0446c4a-c1d4-42e8-88ca-448ea529c7dd/location] to [GET http://localhost:8200/wd/hub/session/285b175b-a798-47e6-bf55-4a41201b7ef0/element/f0446c4a-c1d4-42e8-88ca-448ea529c7dd/location] with body: {}
[JSONWP Proxy] Got response with status 200: "{“sessionId”:"285b175b-…
[JSONWP Proxy] Proxying [GET /element/f0446c4a-c1d4-42e8-88ca-448ea529c7dd/size] to [GET http://localhost:8200/wd/hub/session/285b175b-a798-47e6-bf55-4a41201b7ef0/element/f0446c4a-c1d4-42e8-88ca-448ea529c7dd/size] with body: {}
[JSONWP Proxy] Got response with status 200: "{“sessionId”:"285b175b-…
[JSONWP Proxy] Proxying [POST /touch/longclick] to [POST http://localhost:8200/wd/hub/session/285b175b-a798-47e6-bf55-4a41201b7ef0/touch/longclick] with body: {“params”:{“elementId”:"f04…
[MJSONWP] Encountered internal error running command: {“jsonwp”:{“sessionId”:“285b175b-a798-47e6-bf55-4a41201b7ef0”,“status”:35,“value”:“org.json.JSONException: No value for elementId\n\tat org.json.JSONObject.get(JSONObject.java:389)\n\tat org.json.JSONObject.getString(JSONObject.java:550)\n\tat io.appium.uiautomator2.handler.TouchLongClick.safeHandle(TouchLongClick.java:26)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:54)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:198)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:189)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)\n\tat io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:514)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:468)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)\n\tat io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)\n\tat java.lang.Thread.run(Thread.java:818)\n”}} ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {“sessionId”:“285b175b-a798-47e6-bf55-4a41201b7ef0”,“status”:35,“value”:“org.json.JSONException: No value for elementId\n\tat org.json.JSONObject.get(JSONObject.java:389)\n\tat org.json.JSONObject.getString(JSONObject.java:550)\n\tat io.appium.uiautomator2.handler.TouchLongClick.safeHandle(TouchLongClick.java:26)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:54)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:198)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:189)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)\n\tat io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:514)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:468)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)\n\tat io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)\n\tat java.lang.Thread.run(Thread.java:818)\n”}
at JWProxy.proxy$ (lib/jsonwp-proxy/proxy.js:122:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session/d33767c1-5a17-4904-be59-e0ebbb517c34/touch/perform 500 44 ms - 3314
[HTTP] --> GET /wd/hub/session/d33767c1-5a17-4904-be59-e0ebbb517c34/screenshot {}

If I use the old uiautomator this will work. I tried finding the element by id but I get the same error.

Is there something different I need to do with uiautomator2?

Experiencing the same :frowning:

using latest uiautomator2-driver should fix this issue.