[RN] 수많은 오류(에러) 해결..

juyeong-s·2022년 8월 27일
0

React Native

목록 보기
2/3

진짜 공식 문서만 주의깊게 읽어도 나지 않을 에러들이 많은 것 같다..ㅎ

1. Could not find proper version of cocoapods (1.11.3) in any of the sources Run `bundle install` to install missing gems.

왜 그런지 모르겠다만.. pod install 을 하면 자꾸만 저 에러가 난다. 그럴 경우 하라는 대로 하면된다.
$ bundle install 을 실행후 pod install 을 하면 잘된다.

2. Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

이건 어이없는 오류 ㅎ
이미 실행 중인 포트가 있는 거다. 터미널에서 뭐가 돌아가고 있는지 주의 깊게 보자.. 종료하고 실행하면 잘 될거다

3. mac jdk Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.

1. Android - Preferences에 들어간다. (mac기준) - 윈도우는 File - setting일거다.

2. Build, Execution, Deployment - Build tools - Gradle 에 들어가면 아래와 같은 화면이 보인다.
- 단, 내가 작업하고 있는 폴더의 android 폴더로 프로젝트를 열어 준 뒤 들어가야 한다.
난 그것도 모르고 시작화면에서 Gradle projects가 안보여서 헤맸다

여기서 Gradle JDK를 11버전으로 맞춰주자.
안드로이드를 처음 깐 경우 JDK가 없는 것 같다. 그래서 나는 아래 링크에서 다운로드 받았다.
https://www.oracle.com/kr/java/technologies/javase/jdk11-archive-downloads.html
다운로드 받고 Add JDK로 다운받은 파일을 넣어주면 된다~!

4. Requiring unknown module 'undefined' ~

1. node_module 폴더 및 yarn.lock 파일 삭제
2. $ yarn
3. $ yarn cache clean

5. adb reverse ENOENT

환경변수가 잘못 설정되어서 나는 오류다.
해결법(macOS 기준)**1. bash_profile을 열어준다.**

$ open ~/.bash_profile

2. 다음 환경변수를 맨 아래에 넣어주자. 참고로 open명령어는 메모장처럼 마우스로 조작이 가능하다.

export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH

3. 저장 후 닫기**4. 변경사항 컴파일하기**

source ~/.bash_profile

6. Error while waiting for device: AVD Pixel_2_API_28_2 is already running. If that is not the case, delete the files at C:\Users\UserName\.android\avd/Pixel_2_API_28_2.avd/*.lock and try again.

에뮬레이터를 비정상적으로 종료했을 때 뜨는 오류다. 이상하게 종료 버튼을 눌렀는데 종료가 되지 않았다. 그래서 강제 종료를 하려고 하였으나 그것조차 먹지 않았다..
1. 해당 Virtual Device를 삭제한다. 디바이스의 오른쪽에 점 3개 버튼을 누르면 Delete 할 수 있다.
2. 종료할 때는 에뮬레이터에서 탭의 x버튼을 눌러 지워주면 된다.

7. The following build commands failed: CompileC /Users/ ••• main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler

이럴 경우 pod를 재설치 해주면 된다. 아마 라이브러리를 install 했다가 삭제한 경우 ios와 android에 반영되는 문제 때문에 발생한 것같다.

$ cd ios -> ios 폴더로 이동
$ pod deintegrate -> pod 삭제
$ pod update -> 최신버전으로 업데이트
$ pod install -> Podfile의 라이브러리 재설치

Podfile에 여러 라이브러리가 들어있는 상태에서 install & update하면 라이브러리들이 설치된다.

추가로 아래 명령어를 사용하면 문제가 있는 부분을 진단해준다.

$ npx @react-native-community/cli doctor

참고

react-native android 세팅
https://reactnative.dev/docs/environment-setup#installing-dependencies

https://www.npmjs.com/package/react-native-image-crop-picker?activeTab=versions

https://github.com/ivpusic/react-native-image-crop-picker

 https://github.com/ivpusic/react-native-image-crop-picker

profile
frontend developer

0개의 댓글