본문 바로가기

개발/Android

[android studio] AndroidX 에러 해결 - This project uses AndroidX dependencies

광고를 넣기 위해 Ad view를 추가하고 빌드를 하는데 갑자기 이런 에러가 뜨면서 빌드가 되질 않았다,,

 

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.

The following AndroidX dependencies are detected: androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.core:core:1.0.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.1.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0

 

해결법 1.

AndroidX enable시켜주지 않아서 발생한 것으로 Gradle Scripts - gradle.properties파일에서 하기 두줄만 추가해주면 된다.

android.useAndroidX=true
android.enableJetifier=true

 

그리고 나서 안드로이드 스튜디오 상단 오른쪽에 위치한 Sync Project with Gradle Files 버튼을 클릭해준다.

 

만약 이방법이 통하지 않는다면

해결법 2.

위의 추가한 두줄을 지워주고, Refactor - migrate 메뉴를 클릭한다.

 

 

Run을 시키면 여러가지 리펙터링을 해줄 목록을 띄워주는데 ok눌러주면 알아서 리펙터링이 된뒤 에러가 사라진다.