Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

android - How do I open react-native's dev menu on real device

I have seen already a number of border cases and strange developer interface.

From the "shake your device", which is really impractical, specially with a tablet

To working around Android studio to simulate a button press.

Is there a consistent way to do it? Can't we use a intern API to have a debug button within our app to launch such menu as navigator.popUpDevMenu()?

And if not, how do you shake your tablet to get it working. This is intended to solve How To configure HMR on a real device, too. React native does improve the development experience, but I'd say that particular thing slows it a little bit.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are on a mac, there is a handy tool called Frappe. https://github.com/niftylettuce/frappe

You can use this command from the shell

adb shell input keyevent 82

if haven't run react-native run-android or if the device gets disconnected after you have run the react-native run-android. You need to re-enable the development server port. You can run this command and try again with the previous command

adb reverse tcp:8081 tcp:8081

EDIT: this solution only works for android devices and is among the hacks proposed in the question above. So it is improvable. However It is selected as valid answer until this happens.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...