我使用react-native(在Linux上)创建一些具有客户端-服务器协议(protocol)的android应用程序。这个客户端-服务器协议(protocol)是用 Thrift 制定的。
问题是react-native不能在nodejs环境上运行,而Thrifit库大量使用原生nodejs模块,如util、net、events、tls、child_process、http、https等。我尝试使用 npm install 安装每个模块,但不适用于所有模块。
是否有另一种方法可以将所有 native Nodejs 模块安装到我的 React-Native 应用程序中?有人知道如何使用 Thrift 和 React-Native 吗?
最佳答案
您所说的 Thrift 库是 NodeJS Thrift 库。
Thrift 拥有其他语言的库,例如 Java、Python、C++ 等。
要让 Thrift 在 React Native Android 上运行,我建议您:
- Build the Android thrift libraries 。
- 验证您的 Thrift 客户端是否可以在原生 Android 代码中运行。
- 创建 React Native Native Module (Java 桥接类)。
- 从 React Native Javascript 代码调用您的 Native 模块。
希望这有帮助!
关于android - 如何将 Thrift 模块与 React Native 集成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35122021/