[Android] Set the orientation, but app refused to rotate


I am using Appium v1.3.4.1 and appium-java-client 2.1.0 and I am getting the following error when trying to use AppiumDriver.rotate(ScreenOrientantion orientation)

info: --> POST /wd/hub/session/20134e12-1a9f-4265-b96a-6fb4437092bb/orientation
info: [debug] Pushing command to appium work queue: [“orientation”,{“orientation
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: orientation
info: [debug] [BOOTSTRAP] [debug] Desired orientation: LANDSCAPE
info: [debug] [BOOTSTRAP] [debug] Current rotation: ROTATION_0
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“Set the orientatio
n, but app refused to rotate.”,“status”:13}
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:”
An unknown server-side error occurred while processing the command.”,“origValue”
:“Set the orientation, but app refused to rotate.”},“sessionId”:“20134e12-1a9f-4
info: <-- POST /wd/hub/session/20134e12-1a9f-4265-b96a-6fb4437092bb/orientation
500 2077.327 ms - 216

Here are details about the problem:

  • for some reason, when appium executes the rotation command the AutoRotation function of the device is disabled (don’t know if this is how appium works in the background).
  • the problem only occurs if I wait for the screen to completely load (add waits or Thread.sleep). So for example the rotation occurs WHILE the screen is loading, I do not get the error.
  • the device autorotation LOCK remains active up until the UiAutomator sends the shutdown command, at which point, the app is minimized and the screen ROTATES while the desktop is being loaded. ALSO, if i minimize the app, the rotation occurs as soon as the app is minimized.
  • UPDATE: if I run a command like .openNotifications() before running the rotation command, the rotation time is really low (.2 seconds even lower sometimes), without running a command like this the rotation usually takes .7-.8 seconds). How can this be? :confused:

Can someone help me understand why appium can rotate screens that are loading, but fails to rotate them when you wait for the screen to load successfully?

ALL wait actions return 200 OK in appium server.

Thank you

Are you able to use AppiumDriver?

Rather sse AndroidDriver.

I am using Appium 1.3.4 and Jave 1.8 and it is working fine.

Let us know if it helps.


I have tried everything I found on the web:

  1. use the driver as AndroidDriver
  2. cast the driver to Rotatable
  3. convert the driver to AugmentedDriver (also cast as Rotatable)

All behave the same way. If i rotate while the screen loads (no waits) it works perfectly. If I wait for the screen to fully load, the rotate command returns the error, and the screen ONLY rotates when appium shuts down or I minimize the app.

I have tried on multiple devices and it is the same behavior.

After further investigation it turns out the developers have some orientation lock mechanisms on their screens after the screens are loaded.
I used a workaround to avoid this problem, and this is not an issue anymore.

Hi Sealview,

Could you share your workaround as I 've faced with the same issue


Can you please share the workaround? I am facing the exact issue for my app

The problem was in Android app code. Devs should set orientation reliance to user not to censor.

Below is the code that i tried and is successful too.


I have tried following code but it gives error


org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.07 seconds

Hi Sealview,
Can you please share your solution to this problem?

I tried its working for me in Android.

import org.openqa.selenium.ScreenOrientation;


Hello @Sealview, Others,

I’ve also encountered similar issue and stuck with screen rotations at the moment. Can i someone share work around for this issue.

Your help highly appreciated.


which version of appium did u use? Did u use Emulator or Real device?