296

I am working on a cross-platform React Native mobile app. I am writing console.log statements as I develop. I want to see these logging statements in Chrome while I'm running the Android app in the default Android emulator. According to Facebook's docs I just need to "shake the device". How do I do this in the Android emulator?

To access the in-app developer menu:

On iOS shake the device or press control + ⌘ + z in the simulator. On Android shake the device or press hardware menu button (available on older >devices and in most of the emulators, e.g. in genymotion you can press ⌘ + m to >simulate hardware menu button click)

1
  • Also just wanted to add that the docs also say The Developer Menu is disabled in release (production) builds. So make sure you are not running a release build when you're trying to bring up this menu.
    – BU0
    Commented May 23, 2023 at 17:27

14 Answers 14

319

Within your app in the Android Emulator press Command + M on macOS or Ctrl + M on Linux and Windows.

5
  • 2
    Sadly F2 no longer works on Linux in Android Emulator 2 beta. What now? Commented Mar 30, 2016 at 12:15
  • 7
    @SzczepanHołyszewski I would like to add that, currently in linux, ctrl + m brings up developer menu
    – Ozum Safa
    Commented May 3, 2016 at 20:22
  • the <kbd>f1</kbd>, ... <kbd>f12</kbd> are confusing and difficult to press in most computers
    – ericn
    Commented Aug 19, 2016 at 2:39
  • 3
    I'm probably not going to get any answers on this as this thread is ages old, but I'll say it anyways; This doesn't work for me. Moving the device virtually is not recognized as a shake in my application
    – Pimv_h
    Commented Apr 22, 2021 at 8:05
  • 18
    CMD + M just minimises Android Studio for me. How to open the debug menu inside the emulator?
    – Stuart
    Commented Jan 30, 2023 at 17:32
276

With a React Native running in the emulator,
Press ctrl+m (for Linux, I suppose it's the same for Windows and +m for Mac OS X) or run the following in terminal:

adb shell input keyevent 82
5
  • 2
    Not working for me immediately. I needed to go into "settings" ("...") > Settings > Send Keyboard Shorcuts to > Emulator Controls (not virtual device) then it worked.
    – Ryan Knell
    Commented Oct 30, 2017 at 4:17
  • ctrl + m doesn't work on linux. This adb shell command works even if i would prefer a shortcut....guess i can make one that launch this command if i don't find any other way
    – Laurent
    Commented Jul 8, 2018 at 6:41
  • 1
    To specify a device do adb -s <device id/serial> shell input keyevent 82. I use this when using both an emulator and a physical device. Commented Aug 14, 2019 at 20:42
  • 1
    this answer should marked as the correct answer as its more detailed Commented Nov 4, 2021 at 9:52
  • This is the only solution that worked for me (using Windows)
    – Francis
    Commented Oct 18, 2022 at 15:09
83

If you're using the new emulator that comes with Android Studio 2.0, the keyboard shortcut for the menu key is now Cmd+M, just like in Genymotion.

Alternatively, you can always send a menu button press using adb in a terminal:

adb shell input keyevent KEYCODE_MENU

Also note that the menu button shortcut isn't a strict requirement, it's just the default behavior provided by the ReactActivity Java class (which is used by default if you created your project with react-native init). Here's the relevant code from onKeyUp in ReactActivity.java:

if (keyCode == KeyEvent.KEYCODE_MENU) {
  mReactInstanceManager.showDevOptionsDialog();
  return true;
}

If you're adding React Native to an existing app (documentation here) and you aren't using ReactActivity, you'll need to hook the menu button up in a similar way. You can also call ReactInstanceManager.showDevOptionsDialog through any other mechanism. For example, in an app I'm working on, I added a dev-only Action Bar menu item that brings up the menu, since I find that more convenient than shaking the device when working on a physical device.

6
  • this is not working on MIUI on my mi4i. it just brings up app tray. is there another solution? i really dont want to run it on an emulator as that slows the shit out of my laptop
    – Shreyans
    Commented Apr 21, 2016 at 21:19
  • it seems there are other issues specific to miui. after enabling notification permission i can now shake device to get the menu. check this thread in case anybody else is having issues with MIUI github.com/facebook/react-native/issues/2754
    – Shreyans
    Commented Apr 21, 2016 at 21:42
  • I edited my post to add more detail on how all this stuff works, which may help you track down the problem. My best guess is you're not using ReactActivity and haven't hooked up the menu button through other means. Commented Apr 21, 2016 at 21:45
  • thank you for your prompt response :) though the issue was with MIUI permissions manager which did not let the menu dialog show.
    – Shreyans
    Commented Apr 21, 2016 at 22:28
  • 1
    Nice tip about ReactActivity. Seems like that code has now been moved to ReactActivityDelegate.java
    – Ryan H.
    Commented Mar 29, 2018 at 15:06
39

For Linux you click on the three dots "..." beside the emulator, on Virtual sensors check "Move" and then try quickly moving either x, y or z coordinates.

enter image description here

5
  • 7
    Actually, thats the only solution that worked for me.
    – DsCpp
    Commented Aug 7, 2018 at 16:46
  • 3
    You can also click the device graphic in the window shown and drag it around.
    – brismith
    Commented Dec 19, 2018 at 14:25
  • Any idea how to do this using adb?
    – Himansh
    Commented Oct 23, 2021 at 22:55
  • Only the x direction "shaking" worked for me.
    – yam
    Commented Oct 26, 2021 at 18:44
  • Did not work for me on Mac OS 12.6 & Android Studio 2022.1.1 Patch 2. No amount of shaking on any axis brought up the react native developer menu.
    – BU0
    Commented May 23, 2023 at 16:28
22

'Ctrl + m' works for Windows in the Android emulator to bring up the React-Native developer menu.

Couldn't find that documented anywhere. Found my way here, guessed the rest... Good grief.

By the way: OP: You didn't mention what OS you were on.

0
18

If you want to simulate a 1 second shake from terminal you can use the following command:

adb emu sensor set acceleration 100:100:100; sleep 1; adb emu sensor set acceleration 0:0:0
2
  • For Android studio hedgehog, this was the only thing that worked for me. Thanks for sharing!
    – djthoms
    Commented Jul 6, 2023 at 18:32
  • Works for Android Studio Iguana as well! Commented Mar 7 at 20:02
17

As while developing react native apps, we play with the terminal so much

so I added a script in the scripts in the package.json file

"menu": "adb shell input keyevent 82"

and I hit $ yarn menu

for the menu to appear on the emulator it will forward the keycode 82 to the emulator via ADB not the optimal way but I like it and felt to share it.

enter image description here

2
  • Nice workaround! Commented May 1, 2022 at 14:37
  • Since Emulator settings are unavailable now, this is a solution with the Chipmunk build of AS.
    – DBrown
    Commented Jul 17, 2022 at 19:24
16

I am on Mac OS so when I press Command, it enable zooming option. Here is my solution

  • Open Configuration window [...] button
  • Go toSettings tab ->General tab -> Send keyboard shortcuts to field
  • Change value to Virtual device" as shown in the picture

After that focus on the emulator and press Command + M, the dev menu appears.

Emulator Option -> Settings -> General

2
  • 1
    I'm not sure how to get to these settings? Is this in Android Studio? On the device? I'm using MacOS. Where do I find this?
    – Uch
    Commented May 1, 2023 at 18:43
  • These settings are from the Android Emulator app. Note, this is very different from launching an emulator from within Android Studio. If you launch the emulator from within Android Studio, Android Studio wraps the emulator with it's own trash settings that are different from these. To get what Ponleu has screenshot'd, launch the emulator manually via terminal. Example:emulator -avd Pixel_5_API_33_2. You can use emulator -list-avds to see what emulators you have configured. Docs: developer.android.com/studio/run/emulator-commandline
    – BU0
    Commented May 23, 2023 at 17:23
11

'Command + M' for OSX is working for me.

8

For those for whom Command + M simply minimizes the emulator:

  1. Exit emulator
  2. Go to Setting>Tools>Emulator and uncheck the Launch in a tool window checkbox
  3. Open emulator
  4. now Command + M will open developer menu

enter image description here

0
4

Use command + m(cmd + M) on MAC. Also make sure that you are accessing your application while you try to access the Debug Menui.e. your app must be running otherwise Cmd + M will just return the usual ordinary phone menu.

4

On Linux, Ctrl+M should work, but it doesn’t. To solve the problem, click on the “…” (its extended controls) and then close that window. Now you can open the menu by pressing Ctrl+M. Follow these steps:

  1. Click on the “…” (its extended controls).
  2. Close the extended controls.
  3. Press Ctrl+M.
1
  • For me, this solution almost worked on Linux. I had to press ctrl + m within the extended controls window. Pressing ctrl + m after closing it had no effect.
    – JANO
    Commented Sep 6, 2022 at 9:49
1

It might be not direct solution, but I've created a lib that allows you to use 3 fingers touch instead of shake to open dev menu, when in development mode

https://github.com/pie6k/react-native-dev-menu-on-touch

You only have to wrap your app inside:

import DevMenuOnTouch from 'react-native-dev-menu-on-touch'; // or: import { DevMenuOnTouch } from 'react-native-dev-menu-on-touch'

class YourRootApp extends Component {
  render() {
    return (
      <DevMenuOnTouch>
        <YourApp />
      </DevMenuOnTouch>
    );
  }
}

It's really useful when you have to debug on real device and you have co-workers sitting next to you.

1
  • Yeah, but...shaking it often prepares them for the surprise that is the one day you mistake a cup of chocolate mousse for your cell phone .'* `~. Commented Aug 24, 2021 at 22:49
1

I was trying on a release build via adb install -r -d <app-release>.apk 🤦

Make sure you're running the debug build, then the menu will work via the shortcut or CLI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.