Unable to swipe an mobile element using UIAutomator2

I need to swipe an element in an app from right to left. Using UIAutomator2 touch action is not working .I am unable to swipe.

can you please suggest how to swipe an element from right to left using UIAutomator2.

and your not working code is?

Yes if i use touch action my code is not working

Touch action class is deprecated in java client 8.0.0 version provided by appium.can you please suggest the action class which i can use for swiping an element in place of touch action which is deprecated.

  1. for swipe with UIAutomator2 look here -> https://appium.io/docs/en/writing-running-appium/tutorial/swipe-tutorial/
  2. TouchAction replace with https://appium.io/docs/en/commands/interactions/actions/

a great video as well about interactions: https://www.youtube.com/watch?v=oAJ7jwMNFVU