151

When I switch to landscape mode (NUMPAD 7 or CTRL+F11) the emulator rotates the screen to landscape orientation but the Android OS and none of the apps rotate. So everything is sitting sideways. Is there something in the AVD configuration that needs to be set in order for the device to rotate properly?

enter image description here

Jason Robinson
  • 29,432
  • 18
  • 72
  • 128
Jake Wilson
  • 78,902
  • 83
  • 230
  • 344
  • Wow i've never seen that before...is your program still running in the background? – JPM Sep 12 '11 at 21:50
  • I believe it's a bug with 2.3 + emulator. Try 2.2. – dmon Sep 12 '11 at 21:53
  • As that's on the home screen that's exactly what I'd expect to see. I don't use the emulator but my HTC Desire doesn't switch orientation on any of the home screens when I rotate. – Squonk Sep 12 '11 at 22:04
  • 1
    It doesn't rotate for the home screen or any app or menu, etc. It appears to only do this for the Google APIs (Google Inc.) 2.3.3 API Level-10 AVD. The normal Android 2.3.3 seems to rotate as expected. Not sure if this is a bug or what. – Jake Wilson Sep 12 '11 at 22:06
  • http://stackoverflow.com/questions/4535298/how-to-rotate-android-emulator – Bilal Mujeeb Sep 12 '11 at 22:11
  • I can confirm this. The emulator for Android 2.3.x (2.3.3 and 2.3.1) doesn't handle screen rotation. However, the emaultor for Android 2.2 does handle screen rotation. – Ofir Oct 09 '11 at 10:12
  • Android emulator 2.3.3 does not contain this bug. – user1313024 Aug 29 '12 at 05:11
  • 2
    I have the same problem with Android 4.1 (Google) emulator. Switching keyboard off does not help. – Stan Aug 10 '13 at 19:36
  • I had this problem with an API 4.3 "small phone" and none of the suggestions here worked. However, the big tablet starts horizontally and will (sluggishly) reorient. – CodeClown42 Nov 25 '13 at 16:20
  • See instructions here for manually rotating: http://stackoverflow.com/a/14253321/139560 – Jamie Kitson Apr 23 '14 at 10:04

20 Answers20

129

Another answer here:

in my case the problem was simply that the auto-rotate setting in the android emulator settings (accessible pulling down the notification bar) was disabled, my bad.

abidibo
  • 3,253
  • 2
  • 19
  • 27
  • Doh! That was my problem too, I feel like a dummy. I'm new to Android (used iOS for years) and have realized that auto-rotate is enabled by default on iOS, but disabled by default on Android. – Mike Mar 20 '20 at 21:02
  • 5
    This. I feel that Locked Rotation shouldn't be the default as it throws a lot of new developers off. – Floating Sunfish Jun 04 '20 at 07:30
  • 1
    looks like that's the default setup which is honestly dumb, seeing that I don't know that's disabled without digging into the settings. Google should fix this so that it's on by default. – Eddie Feb 01 '21 at 20:45
  • definitely caught me off guard.. – newLoop Feb 13 '21 at 16:04
61

In my case it was solved by disabling the "Hardware keyboard present" checkbox in the "Edit Android Virtual Device (AVD)" window.

cprcrack
  • 14,411
  • 6
  • 75
  • 83
60

It is a bug with the 2.3 and 4.4 emulators.

http://code.google.com/p/android/issues/detail?id=13189 [v2.3] https://code.google.com/p/android/issues/detail?id=61671 [v4.4]

Himanshu Likhyani
  • 4,289
  • 1
  • 30
  • 32
  • 37
    The problem still happens w/ the Android 4.4 emulator for me as well. Someone else reported it in that thread too :-P – kenyee Nov 28 '13 at 02:27
  • Yes, the problem still exists in Android 4.4.2 emulator. It simply rotates the screen and does not display the corresponding layout file under the corresponding res/layout folder. I have verified this by running in a nexus device where it works as expected. – Rajaraman Mar 09 '14 at 17:53
  • 2
    Android L emulator *also* has this problem. – Max Aug 28 '14 at 03:11
  • As a workaround disable the "Hardware keyboard present" checkbox in the "Edit Android Virtual Device (AVD)" window as @cprcrack sais in http://stackoverflow.com/a/16121394/327786 – TlmaK0 Jan 30 '16 at 11:32
  • 22
    Like if you still see the problem in 2018 – Ninja420 Aug 28 '18 at 14:53
  • 5
    Still happening in 2020. – Oscar Jul 17 '20 at 23:18
  • The valid answer to this issue for 2021 is https://stackoverflow.com/a/52536394/778587 – Eddie Feb 01 '21 at 20:46
35

I spent more time then I'd like to admit scratching my head why my app was rotating fine on my device but not in the emulator... in the emulator pull the drop-down OS menu and make sure "auto-rotate" is enabled. emulator screenshot

Dan
  • 1,222
  • 1
  • 14
  • 22
28

API Level 29 here. By default the rotate is disabled. Pull Down the drop-down of the mobile and enable it.

17

In my case the Skin option in AVD settings was the problem. When I selected "No skin", it worked.

Dino Velić
  • 868
  • 11
  • 24
11

I had same problem. Try removing the "Keyboard lid support" option in the settings of the hardwere virtual machine. It helped me.

5

As of mid 2015 the issue is still open and logged in the android bug tracker here's the link you can check it out https://code.google.com/p/android/issues/detail?id=61671

None of the above solutions worked for me and i am using Android 4.4.2 emulator. As a work around in your graphical layout you can change the orientation and check it out.

Mightian
  • 6,853
  • 3
  • 37
  • 50
4

Once you click the change orientation button, a small icon displays on the emulator asking if you want to change the orientation of the emulated screen. It only displays for a few seconds, so look next to the "bottom" icons and you will see this temporary icon.

This works with the emulator keyboard on or off.

I am running Pixel 2 API 29, Android 10.0 (latest versions as at today)

4

Is the accelerometer property of the emulator set to True? please check it. if not, set it to true. it should help. its working fine on mine.

Open AVD Manager -> GoTo 'Device Definitions' tab -> Select an existing AVD -> Clone

isherwood
  • 46,000
  • 15
  • 100
  • 132
saran
  • 393
  • 1
  • 2
  • 14
  • @Jakobud Open AVD Manager -> GoTo 'Device Definitions' tab -> Select an existing AVD -> Clone – mr5 Jul 12 '14 at 09:18
2

I had to install a new virtual device Nexus on API LEVEL 27 On Api Level 28(PIE) I could not rotate the display.

And it works for me. Regards enter image description here

A. Trejo
  • 561
  • 6
  • 16
1

I got this to work with the latest version of AVD.

Check out the config : Android Config for rotate to work

Also, here is the result: AVD result

I think wha tmakes it click is the combination of keyboard and Skin. Also, if you create your own device make sure you add a Gyroscope sensor.

drew7721
  • 1,503
  • 16
  • 19
1

You have to use Android 5.1.1, aka API 22, aka Android 5.1 LOLLIPOP_MR1. Download Android 5.1.1 (API 22) in your Android SDK Manager and when you create a new Android Virtual Device select that as your OS.

As war_Hero mentioned, this bug was reported to Google. The bug is now fixed as of Mar 23 '15:

https://code.google.com/p/android/issues/detail?id=61671

Lou Morda
  • 4,693
  • 2
  • 40
  • 47
0

I had the same problem, I instantly fixed it by simply deleting the device from the AVD list and just creating a new one.

John Smith
  • 41
  • 1
  • 8
0

Only way to get this to work is to use FroYo API AVD

For anyone with this issue, this is how I set up old Froyo AVD to test this scenario:

My Manifest min version is already 8, which is Froyo

< uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />

You can see SDK_API_VERSION information here. http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

In the SDK manager Installed the needed version:

http://screencast.com/t/KKZokotI4T

Created a new AVD for the new version.

http://screencast.com/t/W8VN6fOWGW

user3618129
  • 85
  • 1
  • 1
  • 7
0

On API level 25 (no skin) it worked after going into the setting, searching for "rotate" and toggling both related settings off and on again.

TomTasche
  • 5,027
  • 6
  • 39
  • 64
0

As of API 29, it stops working randomly for no reason. Need to shutdown and restart emulator, then it works again.

Anton Malyshev
  • 8,035
  • 2
  • 23
  • 41
0

Pixel 2 - API 28 (Android 9)

I had to do this to fix it.

  • Open AVD Manager
  • Select Pixel 2 - API X
  • Edit
  • Show Advanced Settings
  • Untick "Enable keyboard Input"

Only this has worked for me.

Houman
  • 58,044
  • 75
  • 235
  • 407
0

In my case you need to click a small button that would enable the orientation to change, right after you press the main change orientation button.

Rey Monta
  • 21
  • 2
  • Can this be made automatic when changing orientation in the right side bar? – August Oct 09 '20 at 11:14
  • Currently, it is not possible. – Rey Monta Oct 14 '20 at 05:35
  • Actually it works. [https://stackoverflow.com/a/63861830/351688](https://stackoverflow.com/a/63861830/351688) answer works for me. Toggling this setting now automatically changes orientation without having to click an extra button in the emulator – August Oct 14 '20 at 07:24
0

I made a silly mistake and spent a lot of time for the problem on API 30. Checked Auto-rotate setting and other answers here but tried the rotation on the main Android screen, which is not rotated! You need to open some app (your own or a default one, like 'Messages' or 'Browser') to see the rotation works.
enter image description here

Artem Mostyaev
  • 3,589
  • 10
  • 48
  • 55