React Native開發(fā)過程中,在Android模擬器上,commond + m,選擇Debug Js Remotely,模擬器卡在connecting to remote debugger,或者報(bào)錯(cuò)提醒unabled to connect with remote debugger。
解決方法
-
設(shè)置鏈接地址
commond + m-->Dev Setting-->Debug server host & post for device
輸入ip和端口號,如:127.0.0.1:8081 -
命令行設(shè)置模擬器映射端口
adb reverse tcp:8081 tcp:8081
-
以上設(shè)置完成,再執(zhí)行
Debug Js Remotely,就可以鏈接debbger,但是會存在跨域問題。兩種解決方案- 完全退出chrome,命令行執(zhí)行
open -a "Google Chrome" --args --disable-web-security --user-data-dir- 下載chrome瀏覽器插件 Allow-Control-Allow-Origin,安裝之后,開啟跨域模式。