React Native on a machine 8081 occupied

Today, as i was setting up a basic React native app on my company’s laptop, I cannot run the RN packager server which is default to port 8081​. I ran the lsof -i :8081 but get nothing. Turns out I have to run it with sudo because the app that uses this port is the Corporate Mcafee.

Obviously i do not want to uninstall Mcafee from the corporate laptop, I have to find a work around.

First thing to do is to run the packager server in a different port:

react-native start --port 8088

And now the packager server is up and running. However when i run react-native run-android , it still tells me JS server not recognized , so to get rid of this msg, i have to change some source code in the node module. The logic is in node_modules/react-native/local-cli/util/isPackagerRunning.js, and we just need to change the port in the fetch function from 8081 to the 8088 that we use above.

Now the android app should be able to be installed in the virtual device and run. However we still could not leverage the live reload capability of RN because if we double click r to reload, we get a red screen saying cannot connect to 10.0.2.2:8081. This is because when we use Genymotion virtual device, the code in node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java will return that url. So we need to cmd+M in the emulator, Go to Dev Settings → Debug server host for device, enter ‘localhost:8081’. 

This is to overwrite the emulator’s debug server. Now we have the last step which is to forward the request in our local VD’s 8081 port to our machine’s 8088 port which runs the packager server by doing:

adb reverse tcp:8081 tcp:8088

More about adb reverse.

Now you should be able to change your index.android.js and hit r twice or cmd+M -> Reload to reload the VD.

create a quick android app with rss

现在很多的网站都推出了自己的app,但是对于我们这些普通的小网站来说,自己去做一个app有点得不尝试,也没有去那么的精力去做这些,于是就有人做了这样的服务,AppYet就是这样的而一个服务,只要提供网站的feed rss地址,appyet就能自动的生成一个比较perfect的app,只是对于免费的用户, 嵌套了广告,毕竟是免费的,我们也就没有什么可以说的。

appyet是提供了一种服务,只需你提供网站的feed rss,就能很快的生成一个网站的app出来,对于小网站用户来说足矣。(from this blog

对于webvanta, 提供了rss生成script

rss2.0的格式:

  1. <?xml version=”1.0″ encoding=”UTF-8″?>
  2. <rss version=”2.0″>
  3. <channel>
  4.     <title>DotNetBips.com Latest Articles</title>
  5.     <link>www.dotnetbips.com</link>
  6.     <description>DotNetBips.com Latest Articles</description>
  7.     <language>zh-cn</language>
  8.     <copyright>Copyright (C) DotNetBips.com. All rights reserved.</copyright>
  9.     <generator>www.dotnetbips.com RSS Generator</generator>
  10.     <item>
  11.     <title>Using WebRequest and WebResponse</title>
  12.     <link>http://www.dotnetbips.com/displayarticle.aspx?id=239</link&gt;
  13.     <description>Description here</description>
  14.     <category></category>
  15.     <author>Bipin Joshi</author>
  16.     <copyright></copyright>
  17.     <pubDate>Sun, 25 Jan 2004 12:00:00 AM GMT</pubDate>
  18.     </item>
  19. </channel>
  20. </rss>

rss:  每个RSS Feed,都有而且只能有一个rss标签,作为顶层元素,属性version是版本号,如2.0
channel:   在rss标签下,必须有且只能有一个channel标签,可包含