按照步骤此处尝试做出反应- Windows框上的本机android.
Followed the steps here to try react-native android on a windows box.
成功建立 总时间:27.632秒 在模拟器5554上启动应用(D:\ software \ Android \ android-sdk/platform-tool s/adb -s emulator-5554 shell启动-n com.awesomeproject/.MainActivity)... 开始:意图{cmp = com.awesomeproject/.MainActivity}
BUILD SUCCESSFUL Total time: 27.632 secs Starting the app on emulator-5554 (D:\software\Android\android-sdk/platform-tool s/adb -s emulator-5554 shell am start -n com.awesomeproject/.MainActivity)... Starting: Intent { cmp=com.awesomeproject/.MainActivity }
但是我看到一个错误,我很难解决.请提出解决方案.
But I see an error which I'm having hard time to resolve. Please suggest resolution.
---编辑---
可能的问题是McAfee正在使用8081端口.因此,我更新了server.js以在8088上运行开发人员端口,现在当我浏览 localhost:8088/index.android.bundle?platform = android 我可以看到JS正在加载.
Possibly the issue is that 8081 port is in use by McAfee. So I updated the server.js to run dev port on 8088 and now when I browse localhost:8088/index.android.bundle?platform=android I can see JS loading.
但是我如何使android使用此地址而不是默认的** 10.0.2.2:8081 ?**我找到了一个文件AndroidInfoHelpers.java,其中包含该10.0.2.2路径,但不确定是否这就是我可能需要重新编译整个程序的JAVA文件的方式.应该有一种更简单的方法将android应用程序指向开发服务器使用不同的端口.
But how do I make android use this address instead of default **10.0.2.2:8081?** I found a file AndroidInfoHelpers.java which contains that 10.0.2.2 path but not sure if that's the way as being a JAVA file I possibly need to recompile whole program. There should be a simpler way to point android app to use a different port for dev server.
此外,当我执行 react-native run-android 时,输出的第一行显示无法识别JS服务器.继续构建",这可能是在喊同样的话.
Also, when I execute react-native run-android the first line that gets output says "JS Server not recognized.. Continuing with the build" which likely is shouting the same thing.
推荐答案A)设置开发服务器的新端口 用户指令 本机启动--port = 8088 或 yourproject \ node_modules \ react-native \ local-cli \ server \ server.js 设置可用端口,例如8080 现在使用 react-native start 来启动8080上的服务器 B)现在要在模拟器和开发服务器之间建立通信,请使用以下命令 adb -s仿真器-5554反向tcp:8088 tcp:8088 i)5554 =>仿真器端口( adb devices 命令将告诉您仿真器端口,但是如果此命令不起作用,请在中设置路径C:/../android-sdk/platform-tools > Path 环境变量) ii)8088 =>服务器端口
A) Set the new port for dev server User command react-native start --port=8088 or yourproject\node_modules\react-native\local-cli\server\server.js to set the the available port say 8080 now use react-native start to start server on 8080 B) Now to establish communication between emulator and dev server, use below command adb -s emulator -5554 reverse tcp:8088 tcp:8088 i) 5554 =>emulator port (adb devices command will tell you emulator port but if this command is not working then set the path C:/../android-sdk/platform-tools in Path environemnt variable ) ii) 8088 =>server port
C)运行命令 react-native run-android
D)请按照以下步骤在模拟器中更新Dev服务器路径
D) Follow below steps updating Dev server path in emulator
i)Ctrl + M(对于Windows)以打开仿真器的开发菜单. ii)单击开发设置 III)在调试下,选择调试服务器主机&.设备的端口 IV)输入您的应用程序的URL和端口,如10.0.2.2:8088
i) Ctrl + M for windows to open your dev menu for the emulator. ii) Click Dev Settings III) Under Debugging select Debug server host & port for device IV) Enter the url and port for your application as 10.0.2.2:8088
更多推荐
开发服务器返回错误代码403 React Native
发布评论