解决:This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled.

报错信息

FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> 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.lifecycle:lifecycle-runtime:2.3.1, androidx.room:room-runtime:2.2.5, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.version
edparcelable:versionedparcelable:1.1.1, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.sqlite:sqlite:2.1.0, androidx.annotation:annotati
on-experimental:1.1.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.sqlite:sqlite-framework:2.1.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.work:work-runt
ime:2.7.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.arch.core:core-common:2.1.0, androidx.annotation:annotation:1.2.0, androidx.lifecycle:lifecycle-service:2.1.0, androidx.startup:startup-runtime:1.0.0, a
ndroidx.concurrent:concurrent-futures:1.0.0, androidx.room:room-common:2.2.5, androidx.lifecycle:lifecycle-common:2.3.1, androidx.core:core:1.9.0-alpha02, androidx.lifecycle:lifecycle-livedata:2.1.0, androidx.legacy:legacy-support-c
ore-ui:1.0.0, androidx.tracing:tracing:1.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.browser:browser:1.0.0, androidx.lifecycle:lifecycle-livedata-core:2.1.0, androidx.arch.core:core-runtime:2.1.0, androidx.legacy:leg
acy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.recyclerview:recyclerview:1.1.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.core:core-ktx:1.9.0-alpha02, androidx.coordinatorlayout:coordinat
orlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
* 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 1s
F:\MyCode\AndroidStudio\UnityXiaoMiAdsDemo>

解决办法

gradle.properties文件添加:

android.useAndroidX=true // 表示“Android插件会使用对应的AndroidX库,而非Support库”;未设置时默认为false;
android.enableJetifier=true // 表示将依赖包也迁移到AndroidX 。 如果取值为 false,表示不迁移依赖包到AndroidX,但在使用依赖包中的内容时可能会出现问题,当然了,如果你的项目中没有使用任何三方依赖,那么,此项可以设置为 false
posted @   镜子-眼泪  阅读(3207)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
欢迎阅读『解决:This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled.』

喜欢请打赏

扫描二维码打赏

了解更多

点击右上角即可分享
微信分享提示