Unable to connect with remote debugger

后端 未结 14 1134
予麋鹿
予麋鹿 2020-11-28 18:29

I\'m using React.JS and when I do react-native run-android (with my device plugged in) I see a blank page. When I shake the device and select Debug JS Rem

相关标签:
14条回答
  • 2020-11-28 18:57

    I did @sajib s answer and used this script to redirect ports:

    #!/usr/bin/env bash
    
    # packager
    adb reverse tcp:8081 tcp:8081
    adb -d reverse tcp:8081 tcp:8081
    adb -e reverse tcp:8081 tcp:8081
    
    echo "                                                                    
    0 讨论(0)
  • 2020-11-28 19:01

    The other answers here were missing one crucial step for me. In AndroidManifest.xml I needed to add usesCleartextTraffic:

        <application
          ...
          android:usesCleartextTraffic="true">
    

    You probably don't want to keep this in the production release of your app though, unless you want to support insecure http requests.

    After I added this to my AndroidManifest.xml, then I followed Tom Aranda's answer, and the emulator was finally able to connect to the debugger.

    0 讨论(0)
  • 2020-11-28 19:03

    Solved the issue following:

    • Press Cmd + M on emulator screen
    • Go to Dev settings > Debug server host & port for device
    • Set localhost:8081
    • Rerun the android app: react-native run-android

    Debugger is connected now!

    0 讨论(0)
  • 2020-11-28 19:03

    uninstall your application, then run react-native run-android. then click debugging end in chrome replace http://localhost:8081/debugger-ui/, end run react-native run-android. if you still haven't succeeded try again

    0 讨论(0)
  • 2020-11-28 19:08

    In my case the issue was that the emulator was making a request to:

    http://10.0.2.2:8081/debugger-ui

    instead of:

    http://localhost:8081/debugger-ui and the request was failing.

    To solve the issue: Before enabling remote debugging on your emulator, open http://localhost:8081/debugger-ui in chrome. Then enable remote debugging and go back to the chrome page where you should see your console logs.

    0 讨论(0)
  • 2020-11-28 19:09

    In my case, selecting Debug JS Remotely launched Chrome, but did not connect with the android device. Normally, the new Chrome tab/window would have the debugging URL pre-populated in the address bar, but in this case the address bar was blank. After the timeout period, the "Unable to connect with remote debugger" error message was displayed. I fixed this with the following procedure:

    • Run adb reverse tcp:8081 tcp:8081
    • Paste http://localhost:8081/debugger-ui into the address field of my Chrome browser. You should see the normal debugging screen but your app will still not be connected.

    That should fix the problem. If not, you may need to take the following additional steps:

    • Close and uninstall the app from your Android device
    • Reinstall the app with react-native run-android
    • Enable remote debugging on your app.
    • Your app should now be connected to the debugger.
    0 讨论(0)
提交回复
热议问题