• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

[macOS] run android 시 build failed 문제 (build.gradle.kts)

22.11.11 11:04 작성 조회수 1.91k

0

https://reactnative.dev/docs/environment-setup 보면서 기초 세팅 하고나서 프로젝트 생성 후 rpx react-native run-android 명령어를 치면 다음과 같이 빌드에러가 발생합니다.

 

[버전 정보]

macOS: Monterey 12.6.1, 2.7GHz 쿼드 코어 Intel Core i7

node-v: v18.12.1

watchman-v: 2022.11.07.00 

java -version: openjdk version "11.0.17" 2022-10-18 LTS

ANDROID_SDK_ROOT 환경변수 설정 후 adb 명령어 입력: Android Debug Bridge version 1.0.41

공식문서에 나온대로 안드로이드 sdk 31 버전 다운로드하였습니다.

 

[에러 메시지]

~/Desktop/react-native-workspace/AweSomeProject                                                       10:35:46
❯ npx react-native run-android
warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
info JS server already running.
info Installing the app...

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/jihoon/Desktop/react-native-workspace/AweSomeProject/node_modules/react-native-gradle-plugin/build.gradle.kts' line: 12

* What went wrong:
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.6.10']
> Could not resolve all dependencies for configuration 'detachedConfiguration1'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.anypoint.tv/repository/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.5.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

* 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 3s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/jihoon/Desktop/react-native-workspace/AweSomeProject/node_modules/react-native-gradle-plugin/build.gradle.kts' line: 12

* What went wrong:
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.6.10']
> Could not resolve all dependencies for configuration 'detachedConfiguration1'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.anypoint.tv/repository/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.5.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

* 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 3s

    at makeError (/Users/jihoon/Desktop/react-native-workspace/AweSomeProject/node_modules/execa/index.js:174:9)
    at /Users/jihoon/Desktop/react-native-workspace/AweSomeProject/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (/Users/jihoon/Desktop/react-native-workspace/AweSomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/jihoon/Desktop/react-native-workspace/AweSomeProject/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.

 

[build.gradle.kts]

에러의 12번줄에 해당하는 코드 = kotlin("jvm") version "1.6.10"

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import org.gradle.api.internal.classpath.ModuleRegistry
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.configurationcache.extensions.serviceOf

plugins {
  kotlin("jvm") version "1.6.10"
  id("java-gradle-plugin")
}

repositories {
  google()
  mavenCentral()
}

gradlePlugin {
  plugins {
    create("react") {
      id = "com.facebook.react"
      implementationClass = "com.facebook.react.ReactPlugin"
    }
  }
}

group = "com.facebook.react"

dependencies {
  implementation(gradleApi())
  implementation("com.android.tools.build:gradle:7.2.1")
  implementation("com.google.code.gson:gson:2.8.9")
  implementation("com.google.guava:guava:31.0.1-jre")
  implementation("com.squareup:javapoet:1.13.0")

  testImplementation("junit:junit:4.13.2")

  testRuntimeOnly(
      files(
          serviceOf<ModuleRegistry>()
              .getModule("gradle-tooling-api-builders")
              .classpath
              .asFiles
              .first()))
}

java {
  sourceCompatibility = JavaVersion.VERSION_1_8
  targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
  kotlinOptions { jvmTarget = JavaVersion.VERSION_11.majorVersion }
}

tasks.withType<Test>().configureEach {
  testLogging {
    exceptionFormat = TestExceptionFormat.FULL
    showExceptions = true
    showCauses = true
    showStackTraces = true
  }
}

 

프로젝트를 생성하자마자 빌드에러가 떠서 에뮬레이터랑 연결할 수 없네요. 에러 메시지를 보면 maven 리포지토리 주소를 변경하라고 하는 것 같은데 어느 파일에 어느 위치에 변경해야할지 모르겠습니다.

깃헙주소: github.com/kkj0712/AweSomeProject

 

답변 2

·

답변을 작성해보세요.

0

win-s58님의 프로필

win-s58

2022.11.13

답변 주셔서 감사합니다.

알고보니 맥북에서 특수한 maven repository를 바라보도록 설정되어 있었습니다. 제거하고 나니까 필요한 라이브러리들을 찾아서 빌드가 잘 되네요.

혹시나 저같은 에러 메시지가 뜨는 분들이 계시면 컴에 maven 주소가 따로 설정되어있는지 확인해보세요.

0

https://acet.pe.kr/933

이런 식으로 build.gradle 파일에 http 허용을 적어주어야 하는 것 같습니다.