본문 바로가기
안드로이드

Execution failed for task ':app:mergeDebugNativeLibs' 에러 해결

by 코딩히어로 2022. 4. 19.
728x90

안드로이드 그래프를 사용하기 위해 MPChart 라이브러리를 gradle에 추가합니다.

이 과정에서 다음과 같은 에러가 발생하여 해결 방법에 대해 포스팅합니다.

8: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.github.PhilJay:MPAndroidChart:v3.1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/github/PhilJay/MPAndroidChart/v3.1.0/MPAndroidChart-v3.1.0.pom
       - https://repo.maven.apache.org/maven2/com/github/PhilJay/MPAndroidChart/v3.1.0/MPAndroidChart-v3.1.0.pom
       - https://jcenter.bintray.com/com/github/PhilJay/MPAndroidChart/v3.1.0/MPAndroidChart-v3.1.0.pom
     Required by:
         project :app

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
18 actionable tasks: 8 executed, 10 up-to-date

 


제가 gradle에 추가한 방법은 먼저 프로젝트 단위 gradle에

maven {url 'https://jitpack.io'}를 추가하였습니다.

buildscript {
    repositories {
        google()
        maven {url 'https://jitpack.io'}
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

다음으로는 App 수준의 gradle에 MPAndroid 라이브러리를 implementation 하였습니다.

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

여기까지 했을 때 에러가 발생하였는데 왜 발생하는지 여러 가지 자료들을

찾다 보니 정말 간단한 곳에서 해결방법을 알게 되었습니다.

 

근본적인 이유는 AndroidX로 빌드되는 최신 프로젝트에서는 gradle이

프로젝트 단위에 더 이상 라이브러리를 추가하지 않고 setting.gradle이라는

세팅 단위 gradle이 생겨서 이곳에 라이브러리 url을 추가해야 합니다.

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {url 'https://jitpack.io'}
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "TESTAPP"
include ':app'
728x90
반응형

댓글