Expo v27/v28 Android 使用 websocket 的应用程序崩溃
Expo v27/v28 Android App with websocket is crashing
环境: Android 6 Marshmallow 和 iOS(所有版本)
错误: Android 带有 WebSockets 的应用崩溃并出现错误:
WebSocketModule.close got 1 arguments, expected 3.
当我在 Android 关闭 WebSocket 连接时发生错误,例如:
this.ws = new WebSocket(url);
this.ws.onopen = () => {
const command = { command: 'JOIN', room: roonHash };
this.ws.send(JSON.stringify(command));
};
this.ws.onmessage = e => {
//more code here
};
// Finally:
this.ws.close();
iOS:
在 iOS 上工作正常。
我使用的是 Expo v27,但我在 v28 上遇到了同样的错误。
在 Expo/React Native 团队永远修复它之前,是否有解决方法?
世博会 v27
Update your React Native/Expo v27.0.0 to v27.0.2 on your package.json
世博会 v28
Update your React Native/Expo v28.0.0 to v28.0.1 on your package.json
程序:
1) 转到您的 package.json
文件并更改您的 expo 版本,例如:
From:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
To:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.2.tar.gz",
2) 删除你的 node_modules:
$ rm -rf node_modules
3) 重新安装:
$ yarn install
环境: Android 6 Marshmallow 和 iOS(所有版本)
错误: Android 带有 WebSockets 的应用崩溃并出现错误:
WebSocketModule.close got 1 arguments, expected 3.
当我在 Android 关闭 WebSocket 连接时发生错误,例如:
this.ws = new WebSocket(url);
this.ws.onopen = () => {
const command = { command: 'JOIN', room: roonHash };
this.ws.send(JSON.stringify(command));
};
this.ws.onmessage = e => {
//more code here
};
// Finally:
this.ws.close();
iOS: 在 iOS 上工作正常。
我使用的是 Expo v27,但我在 v28 上遇到了同样的错误。 在 Expo/React Native 团队永远修复它之前,是否有解决方法?
世博会 v27
Update your React Native/Expo v27.0.0 to v27.0.2 on your
package.json
世博会 v28
Update your React Native/Expo v28.0.0 to v28.0.1 on your
package.json
程序:
1) 转到您的 package.json
文件并更改您的 expo 版本,例如:
From:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
To:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.2.tar.gz",
2) 删除你的 node_modules:
$ rm -rf node_modules
3) 重新安装:
$ yarn install