normally on Android device I would simply hold the back button to show in app debugging menu, but I've just got this phone and I have no idea how to.
How many ways are there to show in app debugging menu for react native, and is there any specific way for Sony Xperia M4?
I end up using 'adb shell', and run 'input keyevent 82' to show context menu and reload as I wish.
Related
I am using react-native-cli for making a React Native App. It is working fine, and successfully installs on my connected Device but I cannot open the Dev Menu on it.
There is no hardware Menu button, and the shake device ain't working too.
Is there any other way to open the Dev menu?
Or is this bug specific to Xiaomi devices and dev menu cannot be opened on MI?
Phone: Mi Note 3
React Native: 0.39.2
For xiaomi devices, you need to enable popup permission from security->permissions->app name -> popup
Source: https://github.com/facebook/react-native/issues/2754#issuecomment-140815500
On my Redmi 4X i need to hold the "menu" button to open The Dev Menu options.
To verify this option, you can go to:
Settings --> Additional config --> Buttons and gestures shortcuts --> Show menu
PS: As palaniraja said, you need to enable popup permission as well.
I get Xiaomi Mi 8 and, after many hours I have discovered how show the dev menu.
The problem, in this device, is that when you send the command:
adb shell input keyevent 82
is the same that perform a click "menu button" on device.
In brief, if you want to show dev menu on newest devices with miui, you must perform a "long click" on the menu button (NOT A "SIMPLE CLICK")
All the best!
While the device is connected (check adb devices -l), you can use the command:
adb shell input keyevent KEYCODE_MENU
I got strange behavior, when yesterday it worked fine, but today is not working. To fix it,- i restarted device and it helped me.
Make sure you have enable the Display pop-up window
Settings > Permissions > Permissions
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)
Within your app in the Android Emulator press Command + M on macOS or Ctrl + M on Linux and Windows.
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
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.
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.
'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.
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.
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.
'Command + M' for OSX is working for me.
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
on linux ctrl+m should work but it doesn't for solving the problem click on the (...) (its extended controls) and then close that window.now you can open menu by ctrl+m. then:
click on the (...) (its extended controls)
close extended controls
ctrl+m
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.
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.
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.
I'm using Android emulator in Jenkins to run functional tests (Cucumber). Everything works fine if the emulator doesn't contain showcase view at the start.
But if there is a showcase view my tests fail, because application runs behind this view.
I've tried to send keyevents using adb to the emulator before using it:
adb shell input keyevent KEYCODE_MENU;
but it doesn't help. I've tried KEYCODE_MENU, KEYCODE_BACK and other keys, but they don't disable this view.
I guess this property should be available as a system preference in the Android, but I can't find it :(
How can I disable showcase view in emulator? I have access to the emulator using adb.
UPDATE
There's no such flag which can be set in emulator config file or passed to emulator at the start.
And I still don't have a clean solution for this, but few workarounds exist. And that's understandable as showcase view is just a view from Launcher application and logic for that is inside Launcher application.
tricky way, but universal: Prepare custom Android Launcher application with disabled showcase (based on AOSP Launcher) and pre-install (replace default launcher) it on target emulator.
manual way, not universal: gather list of emulators used and coordinates of OK button on those, and send appropriate touch coordinates upon emulator start (as Christopher Orr proposed)
You should be able to send a tap event, for example:
adb shell input tap 700 900
That would tap at approximately the correct x,y pixel coordinate for that button on a Nexus 4.
I'm using eclipse for Android development. Often I have several emulators (and devices) running in order to test my app.
LogCat magically switches to the log from the device I just launched the app on. This is fine most of the time, but sometimes I want to switch back to a different device without restarting an app.
I can't figure out where to select which device LogCat is showing. Where can I change it?
I'm using Eclipse Juno on OS X, if that makes any difference. Here's what my LogCat window looks like:
Go to Window -> Show View -> Devices.
Now you'll have another devices tab present, and in that you can select which device you want to see in the LogCat, as well as the running apps on that device in debug mode.
I am having trouble using the "Screen Capture" function in Eclipse to capture an Android screen shot. I have the correct tab open, and when I click the screen capture icon, the box pops up and just stays on "Capturing..." but the display never changes from a white box with an X through it.
I have USB debugging turned on on the phone and I have the correct device selected in Eclipse..any other tips? Thanks!
Navigate to your android sdk install folder. Open the Tools folder and find DDMS. Run DDMS and use the Screen Capture option from the Device pull down menu. This is the native tool that Eclipse tries to use and it works better natively.
On the screen capture window, click done, then reopen the screen capture dialog. I have to go through this process every time I want screen caps, for some reason it doesn't connect to device on the first run.
This works for me, also when Logcat ceases to work: When I disable and re-enable the debug mode on the device, everything is working again.