19

Is there a way to open dev menu or reload app without shaking the app?

Android Wireless over wifi so no usb cable Windows 10

Hot reload or Live reload is not good enough and my arm hurts :)

Benny
  • 677
  • 1
  • 6
  • 22

11 Answers11

25

for android : in your package.json add following lines in scripts

 "reload":"adb shell input keyevent 82 && adb shell input keyevent 66 && adb shell input keyevent 66",
 "devmenu":"adb shell input keyevent 82",
 "debug":"adb shell input keyevent 82 && adb shell input keyevent 61 && adb shell input keyevent 66 && adb shell input keyevent 66"

now you can run npm run devmenu to open shake menu in android, and reload to reload the app, and debug to connect to remote debugger.

for ios : you can make a button for it somewhere in app, and let this thing only be shown when app is in dev mode.

import {NativeModules,Platform} from "react-native"


renderDevMenuTouchable = () => {
    if(__DEV__ && Platform.OS == "ios" ){
        return (
            <TouchableOpacity
            style={styles.touchableDebug}
            onPress={()=>{
                NativeModules.DevMenu.reload();
            }}
            onLongPress={()=>{
                NativeModules.DevMenu.show();
            }}
            > 
            <View style={{backgroundColor:"red",width:23,height:25}}/>
            </TouchableOpacity>
        )
    }
    else {
        return null;
    }

}
Yash Ojha
  • 792
  • 9
  • 17
  • `devmenu` works nicely here. However, a reload with these options will show `"adb server is out of date. killing..."` . At the next reload, the phone displays a RedBox message with `Could not connect to development server `. In my `react-native run-android` output, I see at the end `adb server version (32) doesn't match this client (41); killing...` so perhaps those two are conflicting. – Julien Lamarche Nov 06 '19 at 22:37
  • why `NativeModules.DevMenu` returns `null` on Android? – Amir Shabani Dec 16 '20 at 13:20
12

As @bennygenel hints, from that page you can see there is a command on Android through adb

adb shell input keyevent 82

to open menu on wireless devices

nicecatch
  • 1,687
  • 2
  • 21
  • 38
  • Working at the moment on trying to get adb to work wireless not successfull – Benny Mar 27 '18 at 16:46
  • (addendum/caveat with my upvote - my device is connected via USB, which isn't available in the body of the question, although it does solve the question as stated in the title...) – Henry Bevan Apr 05 '18 at 10:44
10

I have added Shake gesture to Assistive Touch menu, and this works okay for me.enter image description here

Lazy
  • 670
  • 5
  • 14
7

You can configure long pressing the Android system Recent button to Open/close menu

This would open the dev menu in a react native app.

enter image description here

Shazvi
  • 211
  • 3
  • 6
6

You can send a reload call to the device with: adb shell input keyboard text "rr"

MorenoMdz
  • 316
  • 2
  • 6
1

For iOS I like to wrap my app in a component like this which allows a 3 finger touch to trigger the dev menu:

import { NativeModules } from 'react-native';

// wraps the app in a function to allow three finger dev menu access
const DevMenuTrigger = ({ children }) => {
  const { DevMenu } = NativeModules;
  const panResponder = PanResponder.create({
    onStartShouldSetPanResponder: (evt, gestureState) => {
      if (gestureState.numberActiveTouches === 3) {
        DevMenu.show();
      }
    },
  });
  return <View style={{ flex: 1 }} {...panResponder.panHandlers}>{children}</View>;
};

const DevApp = () => (<DevMenuTrigger><App /></DevMenuTrigger>);

// export default App;
export default DevApp;
user568754
  • 76
  • 5
0

For me only using adb shell input keyevent 82 worked

for convenience you can add it to your scripts inside the package.json file

something link this: "android-menu": "adb shell input keyevent 82"

also apparently there is an issue with KK devices - solved here

Blue Bot
  • 2,278
  • 5
  • 23
  • 33
0

It's also possible to open Debug menu by volume keys in Android. Check the below link.

https://stackoverflow.com/a/59526945/958913

Yogesh Agrawal
  • 971
  • 10
  • 9
0

Not applicable for adb shell input keyevent 82.

When you start the service, a prompt will be printed in the terminal.

"start": "react-native start",

Press d

      Welcome to Metro!
Fast - Scalable - Integrated

To reload the app press "r"
To open developer menu press "d"
weiya ou
  • 2,730
  • 1
  • 16
  • 24
0

Another way to achieve this is by:

typing "d" in the terminal where you're running the Metro server (basically the terminal where you've typed in "yarn/ npm start"
Gaurav Joshi
  • 89
  • 1
  • 2
0

Flipper has a button for it on the top left:

Flipper Reload App Button

zeusstl
  • 1,673
  • 18
  • 19