[英]Android Emulator cannot connect to React-Native remote debugger - Timeout while connecting
[英]React-native 0.21 (android) remote debugger (Chrome) cannot connect
我的遠程調試(通過Chrome使用React-native dev工具0.14.8)以前工作正常。
我不確定兩者之間究竟發生了什么(我升級到react-native 0.21,對android studio進行了更新,使用apt-get update / upgrade更新了Linux Mint 17.3)。
但現在我所看到的是“請等待連接到遠程調試器”在我的模擬器上大約5-8秒,然后我收到錯誤(參見附圖): “無法連接遠程調試器”
我嘗試重新安裝Chrome React原生擴展程序。 嘗試重建我的應用程序。 沒有幫助。 我不確定問題出在哪里。 可能我只需要增加連接超時的值..但似乎沒有這樣的選項。
下面也是我的package.json(由於各種依賴性問題,需要花費幾天的時間來完成0.20到0.21的升級)。 可能有一個我失蹤的新設置,有人可以指出。
{
"name": "ftesting",
"version": "1.0.0",
"description": "ftesting desc",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node_modules/react-native/packager/packager.sh",
"android-setup-port": "adb reverse tcp:8081 tcp:8080",
"test": "eslint ./src/js.app/my.forms",
"start": "rnws start",
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
"postinstall": "npm run clean:babelrc"
},
"repository": {
"type": "git",
"url": "xyz" },
"keywords": [
"ftesting"
],
"author": "ls",
"license": "MIT",
"engines": {
"node": ">=4",
"npm": ">=2 <4"
},
"devDependencies": {
"babel-eslint": "^6.0.0-beta.1",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"eslint": "~2.2.0",
"eslint-loader": "^1.1.1",
"eslint-plugin-react": "^4.2.0"
},
"dependencies": {
"react-native": "^0.21.0",
"@remobile/react-native-splashscreen": "^1.0.3",
"react-native-blur": "^0.7.10",
"react-native-htmlview": "^0.2.0",
"react-native-material-kit": "^0.3.0",
"react-native-material-design": "^0.3.3"
}
}
這個問題發布了一個github問題。 你可以關注: https : //github.com/facebook/react-native/issues/6390
也許這對其他人來說是愚蠢的問題,如果它有幫助,對我來說,當我連接wifi時問題解決了(我已斷開它:)
我意識到這是一個連接問題,當我從瀏覽器請求反應本機的url獲取index.bundle(設備應用程序中的配置設置中的那個)並發現它可以訪問...
我正在使用0.25.0-rc
它現在肯定在工作。 使用0.25.1測試查看鏈接的github問題中的回復。
總的來說,我認為最大的問題是,一旦本機團隊解決了0.21中引入的原始問題,他們就改變了構建應用程序的方式。
如果你沒有改變,錯誤是顯着的。 因此在調試/構建過程中無法捕獲它。
基本上從2016年2月開始,您不再需要從maven存儲庫中提取react-native jar。 相反,您需要將gradle.build指向npm-modules位置的react-native jar
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../../node_modules/react-native/android"
}
}
}
然后
compile "com.facebook.react:react-native:+"
上面這些變化的組合,允許我鏈接到react-native jar的最新副本,而不是從maven中拉出0.20.1(並注意到maven的0.20.1自2016年2月以來未被修改)。
這適用於使用react-native init或從expo中彈出的應用程序。 啟動de app:
react-native run-android
模擬器將顯示紅屏調試器連接錯誤(這就是我們首先在這里的原因)。
使用模擬器對焦按:
Ctrl+M
或者來自shell問題:
adb shell input keyevent KEYCODE_MENU
將在應用程序開發人員菜單中顯示:
點擊進入
Dev settings
選擇選項:
Debug server host & port for device
並輸入:
localhost:8081
現在我們將在模擬器中的端口8081中進行調用,轉到主機上的同一端口。 從shell做:
adb reverse tcp:8081 tcp:8081
准備好了,只需重啟應用即可
react-native run-android
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.