解決: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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM