Need help on Andriod app automation using UIAutomator2 tool

I am working on automation of an app and there is as per requirement for andriod device need to be automated using UiAutomator2.I have not worked on this tool anytime.I have worked on Appium earlier.It will be helpful if anyone can share the sample script as i don’t know how to pass locators and set desired capabilities.Thanks in advance!!

@AmTech simple example: https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/appium/AndroidTest.java and tons around in near folders.

@Aleksei Thank you so much for quick reply and also for sharing the information.
I had gone through couple of examples and got a glimpse that UIAutomator2 is mainly used as locator technique and the driver which we use is still an Andriod driver.Plese correct me .

@AmTech true. Driver remains the same. With latest android version old automator may not work. Just stopped support from google.

@Aleksei thank you so much .
Will follow the repo and will start working on it .