[React Native] Firebase native android build error 오류해결!

bi_sz·2023년 11월 22일
1

ReactNative

목록 보기
34/37
post-thumbnail

RN 프로젝트를 진행하면서 그 동안은 Android Studioemulator 로 실행하면서 문제없이 사용하고 있었습니다.

Firebase 를 연동해서 사용하려다보니 Vscode 에서 npm rum android 명령어로 실행하려니 build 오류가.....

정말 어지러운 오류입니다.


⭐ 해결방법

💫 1. React-Native Doctor

> react-native doctor

해당 명령어를 실행하면 React-native 를 실행하는 데에 어떤 에러가 있는지 확인할 수 있습니다.

자세한 에러내용 전부를 볼 순 없지만 크게 어떤 문제가 있는지 알 수 있습니다.

분명 RN 관련 라이브러리들은 다 받아준 것 같은데 ㅎㅎ
설치보다는 npx 를 자주 사용해서 그런지 제대로 안 받아진건지 뭔지는 모르겠지만 npx 로 사용 가능하면 됐지.. 싶습니다.

> react-native doctor
> npx react-native doctor

react-native 명령어가 듣지 않으면 npx 로 시키면됩니다.

  • Adb(Android Debug Bridge) : 연결된 기기나 애뮬레이터가 없다는 것으로 보입니다.
  • JDK(Java Development Kit) : 설치된 JDK 버전이 낮습니다.
  • Android SDK : 현재 설치된 Android ADK 버전이 확인되지 않습니다.

저한테 발생한 오류는 위와 같습니다.
다른 자바 프로젝트를 작업하면서 1.8 버전을 쓰고있는데,,, 11 이상~
안드로이드 스튜디오도 인식하지 못하고 있습니다.

🔸 Adb

https://velog.io/@bi-sz/ReactNative-Expo-Android-Studio
매번 안드로이드 스튜디오 키는게 귀찮아서 cmd 에서 명령어로 emulator 를 실행해주면서 환경변수를 설정했었습니다.

emulator 만 들어가있고 나머지는 빠져있었어서 추가해주었습니다.

환경변수를 추가해주었더니 기존에 X 표시이던 Adb 가 해결되었습니다.

🔸 JDK

Java11 를 추가로 설치해주었습니다.

Vscode 에서 JAVA11 로 실행해주었습니다.

💫 2. Gradle 설치

BUILD FAILED in 4s
Error: D:\ReactNativeVsWorkspace\firebase-intagration-authentication\android\gradlew.bat exited with non-zero code: 1

_gradlew.bat_ 가 0이 아닌 코드로 종류되었습니다. 라는 오류가 발생했을 때의 해결법을 검색하다보니

https://stackoverflow.com/questions/73395968/gradlew-bat-exited-with-non-zero-code-1-react-native

해당 커뮤니티에서 Gradle 이 설치되어있는지 확인하라는 내용이 있었습니다.

https://velog.io/@bi-sz/Gradle
문제를 해결하면서,, Gradle 설치 과정을 정리해두었습니다.

Gradle 이 설치되어 있는지 확인합니다.

> gradle -v

⭐ 오류 해결!

빌드가 성공하고 ㅜㅜ

이 화면이 뭐라고 이렇게 보고싶었는지....


🌟 해결 기록

  1. Gradle 설치
  2. Java 버전 변경

저는 Gradle 을 먼저 설치하고 Java 버전을 변경하여 오류를 해결했습니다.

react-native doctor 라는 것을 Gradle 설치 이후에 알게되어서 순서가 저렇게 되었는데, Gradle 을 설치하지 않아도 해결될지는 모르겠습니다.

react-native doctor 먼저 해본 후에 오류를 해결하고 build 관련 오류가 계속 뜬다면 Gradle 을 설치해주면 될 것 같습니다.

실행에 성공하고 나서 react-native doctor 를 한 결과입니다.

Android SDK 부분이 계속 버전을 못 찾아서 안드로이드 환경 변수 설정이나 세팅을 다시 해주었는데, 해결이 되지 않아서 Java 부터 바꿔보자~ 하고 변경했더니 오류가 해결이 된 경우여서 SDK 버전을 읽어오지 못 하는 것은 실행에는 문제가 되지 않아 일단 배제하였습니다..

언젠간 고치겠지~


🌠 오류 본문

저와 같은 문제를 겪은 분들이 빠르게 문제 해결을 하시길 기원하며,,, 오류 본문을 첨부하였습니다.

* What went wrong:
A problem occurred configuring root project 'firebase-intagration-authentication'.
> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':classpath'.
      > Could not resolve expo.modules:expo-dev-launcher-gradle-plugin.
        Required by:
            project :
         > No matching variant of project :expo-dev-launcher-gradle-plugin was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0.1' but:
             - Variant 'apiElements' capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'mainSourceElements' capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified declares a component, and its dependencies declared externally:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
                     - Doesn't say anything about its usage (required runtime)
             - Variant 'runtimeElements' capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8     
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'testResultsElementsForTest' capability expo.modules:expo-dev-launcher-gradle-plugin:unspecified:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
                     - Doesn't say anything about its usage (required runtime)
      > Could not resolve com.android.tools.build:gradle:7.4.2.
        Required by:
            project :
         > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0.1' but:
             - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a component for use during runtime, and its dependencies declared externally:
                 - Incompatible because this component declares documentation and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8     
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a component for use during runtime, and its dependencies declared externally:
                 - Incompatible because this component declares documentation and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
      > Could not resolve com.facebook.react:react-native-gradle-plugin.
        Required by:
            project :
         > No matching variant of project :gradle-plugin was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0.1' but:
             - Variant 'apiElements' capability com.facebook.react:react-native-gradle-plugin:unspecified declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'mainSourceElements' capability com.facebook.react:react-native-gradle-plugin:unspecified declares a component, and its dependencies declared externally:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
                     - Doesn't say anything about its usage (required runtime)
             - Variant 'runtimeElements' capability com.facebook.react:react-native-gradle-plugin:unspecified declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8     
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
             - Variant 'testResultsElementsForTest' capability com.facebook.react:react-native-gradle-plugin:unspecified:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
             - Variant 'testResultsElementsForTest' capability com.facebook.react:react-native-gradle-plugin:unspecified:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
                     - Doesn't say anything about its usage (required runtime)

* Try:
> Run with --stacktrace option to get the stack trace.
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.0.1')
                     - Doesn't say anything about its usage (required runtime)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Error: D:\ReactNativeVsWorkspace\firebase-intagration-authentication\android\gradlew.bat exited with non-zero code: 1
Error: D:\ReactNativeVsWorkspace\firebase-intagration-authentication\android\gradlew.bat exited with non-zero code: 1
    at ChildProcess.completionListener (D:\ReactNativeVsWorkspace\firebase-intagration-authentication\node_modules\@expo\spawn-async\build\spawnAsync.js:52:23)
    at Object.onceWrapper (node:events:629:26)
    at ChildProcess.emit (node:events:514:28)
    at cp.emit (D:\ReactNativeVsWorkspace\firebase-intagration-authentication\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5)
    ...
    at Object.spawnAsync [as default] (D:\ReactNativeVsWorkspace\firebase-intagration-authentication\node_modules\@expo\spawn-async\build\spawnAsync.js:17:21)
    at spawnGradleAsync (D:\ReactNativeVsWorkspace\firebase-intagration-authentication\node_modules\@expo\cli\build\src\start\platforms\android\gradle.js:72:46)
    at Object.assembleAsync (D:\ReactNativeVsWorkspace\firebase-intagration-authentication\node_modules\@expo\cli\build\src\start\platforms\android\gradle.js:52:18)
    at runAndroidAsync (D:\ReactNativeVsWorkspace\firebase-intagration-authentication\node_modules\@expo\cli\build\src\run\android\runAndroidAsync.js:36:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

0개의 댓글