Shake gesture on Android Emulator — react-native

Suraj M Durgad
3 min readSep 17, 2022

--

Hey everyone, I’m back again with a small tutorial to make your life easier as a react-native developer.

I’m pretty sure you might have faced this screen whenever you tried to run your app on Android Emulator.

This looks great but the only problem is, your shortcut to shake the screen to open up react native debug tools or the shortcut to rotate your Emulator to landscape or any other shortcuts for that matter wouldn’t work, which is just a deal breaker.

When you google about it you see all complex suggestion like
1. Adding a key-event to your package.json
2. Setting virtual keyboard
and many more… and none of those work for their respective reasons.

So I’ll try to provide you a simple solution to resolve this issue.

First let’s try to understand the problem, when ever you run the emulator it creates the emulator within the instance of the Android Studio and all the keyboard inputs you enter are received by Android Studio IDE and not the Emulator. That’s the reason the the shortcuts don’t do what they are expected to do. So in order to address this issue the Emulator should be run as a separate instance from IDE to receive those key-events/shortcuts.

Now how would you do that?

Step 1—

Open Preferences/Settings on Android Studio and navigate to Emulator.

Now deselect the Launch in a tool window option which would be enabled by default. If you further read the description of this option you’ll notice it basically starts the emulator as a separate instance / standalone application.

Step 2 —

Close all the Emulators if you are running any and restart your IDE.

Voilà!

If you have followed the above steps correctly. The next time when you run the Emulator after restarting the IDE by hitting the play button,

it would start a separate instance for the Emulator which would be able to receive all your key board shortcuts which were received by the IDE instead of the Emulator.

For example —

  1. In Linux when you hit Cmd + m it opens up debug menu options for react native.
  2. Cmd + → will rotate your simulator to landscape.

Hope this makes your life a tad bit easier, if yes, I wouldn’t mind some claps. #shamelessplug

Follow me @surajmdurgad on any platform.

Do let me know if it helped you.

Until next time! 👋🏻

Cheers! 🍻

--

--

Suraj M Durgad
Suraj M Durgad

Written by Suraj M Durgad

Mobile Engineer @quizizz, ping me @surajmdurgad

Responses (1)