React-native 0.21(android)远程调试器(Chrome)无法连接

时间:2016-03-13 17:41:06

标签: react-native

我的远程调试(通过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"
    }
}

4 个答案:

答案 0 :(得分:2)

此问题已发布github问题。你可以按照那里: https://github.com/facebook/react-native/issues/6390

答案 1 :(得分:0)

对于其他人来说,这可能是个愚蠢的问题,如果它有帮助,对我来说,当我连接wifi时问题就解决了(我断开了它):

我意识到这是一个连接问题,当我从浏览器请求反应原生的url获取index.bundle(设备应用程序中的配置设置中的那个)并发现它可以访问...

我正在使用0.25.0-rc

答案 2 :(得分:0)

现在肯定有用了。 用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:+"

上述这些变化的组合,允许我链接到反应原生jar的最新副本,而不是从maven中拉出0.20.1(并注意到maven的0.20.1自2016年2月以来未被修改)。

答案 3 :(得分:0)

这适用于使用react-native init创建或从expo弹出的应用。 从以下位置启动应用程序:

$all = Exam::with(['questions','questions.choices'])->where('exam_id', $examID)->get();

仿真器将显示红屏调试器连接错误(这就是为什么我们首先出现在这里)

使仿真器处于聚焦状态,然后按:

react-native run-android

或来自shell问题:

Ctrl+M

应用程序内开发人员菜单将出现:

点击

adb shell input keyevent KEYCODE_MENU

选择选项:

Dev settings

然后输入:

Debug server host & port for device

现在,我们将在仿真器的8081端口中调用与主机上相同的端口。 从外壳执行:

localhost:8081

准备就绪,只需重新启动应用程序

adb reverse tcp:8081 tcp:8081
相关问题