Screen orientation is not working in Appium 1.17.1 - URGENT

I have trying to rotate the screen from portrait to landscape mode. It’s not working. Same code worked in previous versions

Real Device: SAMSUNG TABLET (OS Android 9)

Tried with

Appiumdriver.rotate(ScreenOrientation.LANDSCAPE);

Also tried with Android driver too

Error Message : org.openqa.selenium.InvalidElementStateException: Set the orientation, but app refused to rotate

Both are not working. Kindly help

I had the same issue while using it using python. This solved it:

driver.orientation = ‘LANDSCAPE’

Hope it helps.