2016년 1월 27일 수요일

Windows 환경에서 React native Getting started sample project 실행하기.

Windows laptop에서 React Native Getting started sample인 AwesomeProject를 돌려보고자 하였음.

React Native Getting started.
https://facebook.github.io/react-native/docs/getting-started.html

- Homebrew => Scoop (https://www.outcoldman.com/en/archive/2014/07/20/scoop/)
대체 하여 사용할 수 있지만 정작 watchman, flow는 scoop을 사용해서 설치 못함.
curl, git, nodejs 같은 기본적인 것들은 설치 가능함.
 : proxy 설정 : https://github.com/lukesampson/scoop/wiki/Using-Scoop-behind-a-proxy

Android Setup guide
: https://facebook.github.io/react-native/docs/android-setup.html

- 프로젝트 빌드 시 guide에서 표시한 대로 SDK builde tool 23.0.1 은 설치가 되어야 함.

- emulator 실행 설정에 실패함.
 : Android SDK의 emulator는 부팅은 되지만 정작 실행이 안된다. HAXM install에도 불구하고 실행이 안된다.
 : Windows에서 제공하는 Hyper-V 기반으로 emulator를 실행하였지만 "preparing virtual machine" 메세지만 표시되고 실행이 안된다. 좀 Hyper-V 관련 trouble shooting을 찾아봤지만 내 환경 설정이 좀 문제인듯.
=> 그래서 그냥 device 연결해서 AwesomeProject 실행.

- 두 개의 shell에서 "react-native start" 실행 후 "react-native run-android" 실행
- 실행 시 JS load에 문제가 생겼다는 메세지와 빨간 화면 표시
 : bundle js 파일이 asset에 포함되지 않아서 생긴 known issue인 듯 아래 처럼 필요한 다운로드 하면 된다.
 => http://stackoverflow.com/questions/32572399/react-native-android-failed-to-load-js-bundle

Update

To run with local server, run the following commands under your react-native project root directory

  1. react-native start > /dev/null 2>&1 &
  2. adb reverse tcp:8081 tcp:8081
please take a look at dsissitka's answer for more details.

To run without a server, bundle the jsfile into the apk by running:

  1. create an assets folder under android/app/src/main
  2. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
please take a look at kzzzf's answer for more details.
shareimprove this question

windows 기반에서 React native project를 실행은 했으나...
개발을 위해서 맥북을 사야하나라는 생각이 마구마구 듬.

댓글 없음:

댓글 쓰기