반응형

npm install -g react-native-cli

or

npm install -g expo-cli

 

 

프로젝트 생성

react-native init [프로젝트명]

or

expo init [프로젝트명]

 

cd [프로젝트명]

 

=== react-native

npm start ==> 프로젝트 시작

 

또 다른 창에 (실행했는데 에러난다면)

android/app/src/main 폴더에서 assets 폴더 생성

 

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

 

--platform android : 안드로이드 빌드

--dev false: 릴리즈 모드로 빌드

--entry-file index.js : index.js를 시작으로 번들링 할 것

--bundle-output *** : 번들결과 파일 위치 및 파일명 설정

--assets-dest *** : 리소스 경로 설정

 

끝나면

react-native run-android ==> simulator 가 뜬다

 

 

==== expo

yarn start 

 

 

 

 

빌드는?

 

번들링 생성 시

cd android

./gradlew bundleRelease

 

or

cd android && ./gradlew bundleRelease

 

여러번 빌드하다보면 번들링 결과가 여러번 생성되므로 정리해주자.

cd android && ./gradlew clean && ./gredlew bundleRelease

 

 

apk 생성해야한다면 assembleRelease 

cd android && ./gradlew assembleRelease

 

 

빌드 후 android/app/build/outputs에 결과 파일 생성

 

 

 

release 버전으로 구동 테스트할 때는 --variant=release 옵션을 넣고 실행하면 된다.

react-native run-android --variant=release

 

빌드 옵션 상세 ./gradlew bundleRelease 의 상세

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

 

--platform android : 안드로이드 빌드

--dev false: 릴리즈 모드로 빌드

--entry-file index.js : index.js를 시작으로 번들링 할 것

--bundle-output *** : 번들결과 파일 위치 및 파일명 설정

--assets-dest *** : 리소스 경로 설정

 

반응형

+ Recent posts