개발

react-native 복사한 프로젝트 apk 생성

고양이양말 2022. 6. 16. 16:55

 

1. 기존 프로젝트를 복사할 경우 기존에 열려있던 node command 창과 Android Studio를 모두 닫는다.

2. 복사한 프로젝트를 열어서 수정할 부분 수정하고..(company나 app name 등)

3. 아래 명령어 실행하여 index.android.bundle을 재설정한다.

% npx 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/

4. 단말기를 연결하고 프로젝트 폴더에서 % npx react-native run-android로 실행하여 test

5. Android Studio에서 Build > Clean Project, Rebuild Project 다 해본다.

6. Build > Build Bundle(s) / APK(s) > Build APK(s)

 

위의 과정을 거치지 않으면 Invariant Violation: has not been registered 에러가 발생할 수 있다.

Invariant Violation: "..." has not been registered. This can happen if:
    * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
    * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

(현재 소스 수정 후 apk를 만들려면 매번 bundle를 다시 생성해줘야한다.. 테스트가 더 필요)