본문 바로가기
개발 환경 구축

WSL2 환경에서 react native 실행 시 오류

by 두꺼비사장 2023. 9. 28.
728x90

 Window안의 ubuntu 환경인 WSL2에서, 아래 명령을이용하여  react native project를 생성하고,

npx react-native init 앱이름

다시 아래 명령을 이용하여 예전에 window 환경에서 설치한 visual studio emulator를 실행 할 때   

npm run android

아래 에러가 발생 하였습니다.

 

youtube/블로그에 정확한 해결 방법이 없어서 거의  반나절 삽질을 해서 해결한 오류 들인데, 발생했던 오류 및 해결한 방법을 공유 합니다.

 

ERROR1 :Could not determine the dependencies of task   

[에러 내용]
Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac’.
> SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project’s local properties file at ‘/Users/macbook/Desktop/Items/jobpost/android/local.properties’.

[해결 방법]

window file system에 저장된 android studio sdk의 path를  .bashrc 파일에 설정 하여 해결

  1. .bashrc 파일 open
     vi ~/.bashrc
  2. .bashrc 파일 맨 아래에 아래  2줄 삽입
    export WINDOWS_C_DRIVE="/mnt/c/"
    export ANDROID_HOME="$WINDOWS_C_DRIVE/Users/USERNAME/AppData/Local/Android/Sdk"
     (여기서 USERNAME은 본인의 username을 확인 해서 설정)

 

ERROR2 : SDK location not found 

[에러 내용]
Build-tool 30.0.3 is missing AAPT at /mnt/c/Users/voip7/AppData/Local/Android/Sdk/build-tools/30.0.3/aapt
5 actionable tasks: 5 up-to-date

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not determine the dependencies of null.
   > Installed Build Tools revision 30.0.3 is corrupted. Remove and install again using the SDK Manager.

[해결 방법]

Android studio를 실 행 한 후 File > Settings > Appearnace & Behavior > System Settings > Android SDK 에 들어가서

SDK Tools을 선택 후 아래의 그림처럼,

30.0.3 uncheck 하고, 주위의 30.0.1, 30.0.2 SDK를 설치 하니 위 에러가 해결이 되었다.