Mobile Develop/Android

Dependency 버전 오류 해결하기

nyangzzi 2024. 1. 13. 18:05
반응형

 

안드로이드 프로젝트에 새로운 모듈을 추가하던 도중 다음과 같은 오류가 발생하였다

상당히 자주 보는 오류 😂

 

3 issues were found when checking AAR metadata:

  1.  Dependency 'androidx.activity:activity-ktx:1.8.0' requires libraries and applications that
      depend on it to compile against version 34 or later of the
      Android APIs.

      :app-demo-compose is currently compiled against android-33.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.4.2 is 33.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 34, then update this project to use
      compileSdkVerion of at least 34.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).

  2.  Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that
      depend on it to compile against version 34 or later of the
      Android APIs.

      :app-demo-compose is currently compiled against android-33.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.4.2 is 33.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 34, then update this project to use
      compileSdkVerion of at least 34.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).

  3.  Dependency 'androidx.activity:activity-compose:1.8.0' requires libraries and applications that
      depend on it to compile against version 34 or later of the
      Android APIs.

      :app-demo-compose is currently compiled against android-33.

      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 7.4.2 is 33.

      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 34, then update this project to use
      compileSdkVerion of at least 34.

      Note that updating a library or application's compileSdkVersion (which
      allows newer APIs to be used) can be done separately from updating
      targetSdkVersion (which opts the app in to new runtime behavior) and
      minSdkVersion (which determines which devices the app can be installed
      on).

 

 

Dependency 'androidx.activity:activity-ktx:1.8.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs.

 

해석해 보면 androidx.activity:activity-ktx:1.8.0 버전은 최소 android sdk 34버전부터 지원한다는 뜻이다.

 

:app-demo-compose(현재 나의 모듈)  is currently compiled against android-33.
Also, the maximum recommended compile SDK version for Android Gradle plugin 7.4.2 is 33.

 

하지만 현재 개발 중인 모듈은 33 버전을 타겟팅하고 있으므로 호환이 불가하다.

 

따라서 개발 중인 모듈의 버전을 34로 올려주거나, 가지고 온 라이브러리를 33부터 지원되는 버전으로 낮춰 호환되는 버전으로 세팅해주면 문제가 해결된다.

 


 

하지만 이렇게 해도 문제가 해결되지 않는 경우가 있다..

androidx.activity:activity-ktx 라이브러리는 해당 프로젝트에서 사용하고 있지 않기 때문이다.

 

이런 경우, 의존성을 주입한 라이브러리 중 androidx.activity:activity-ktx에 종속성을 가지고 있는 경우가 있을 수 있다.

위 프로젝트의 경우 material 라이브러리에서 문제가 발생했다.

 

https://github.com/material-components/material-components-android/releases/tag/1.10.0

 

Release 1.10.0 · material-components/material-components-android

What's new since 1.9.0 Added Predictive back support for search, bottom sheet, side sheet and navigation drawer. Check out the developer documentation for more details. Add Start-aligned variant t...

github.com

 

문제가 된 material 라이브러리 버전은 1.10.0으로, 위의 릴리즈 노트를 확인해보면 sdk 34부터 사용 가능하며

activity 라이브러리에 종속성을 가지고 있는 것을 확인할 수 있다.

 

 

따라서 com.google.android.material:material 버전을 sdk 33을 지원하는 1.9.0으로 낮추면 문제가 해결되는 것을 확인할 수 있다!

 


 

라이브러리 버전 맞추는 건..

매번 해도 매번 어렵다

 

참고

 

Gradle keeps promoting dependency version in my Android Compose project

So in my project, Gradle keeps promoting my android compose library (to be specific: 'androidx.activity:activity-compose') to the latest 1.8.0-alpha05 version. However, this version requires compil...

stackoverflow.com

 

반응형