最近遇到一個合作專案,公司的專案是依賴于Androidx,合作公司的專案是依賴于support,需要我將公司專案回退到依賴于support,我把gradle.properties中關于參考Androidx的兩個屬性
android.useAndroidX=true
android.enableJetifier=true
改成了false,并且將app下的build.gradle中依賴于Androidx的庫一一替換成support的庫,將專案中所有關于參考Androidx的地方改成了support對應的,最后編譯專案沒問題,run的時候還是會報錯,提示
Execution failed for task ':testlibrary:generateDebugRFile'.
> 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.appcompat:appcompat:1.1.0, androidx.versionedparcelable:versionedparcelable:1.1.0, androidx.fragment:fragment:1.1.0, androidx.core:core:1.2.0, androidx.annotation:annotation-experimental:1.0.0, androidx.customview:customview:1.0.0, com.google.android.material:material:1.2.1, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.viewpager2:viewpager2:1.0.0, androidx.activity:activity:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.collection:collection:1.1.0, androidx.viewpager:viewpager:1.0.0, androidx.cardview:cardview:1.0.0, androidx.arch.core:core-common:2.1.0, androidx.savedstate:savedstate:1.0.0, androidx.annotation:annotation:1.1.0, androidx.lifecycle:lifecycle-common:2.1.0, androidx.appcompat:appcompat-resources:1.1.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.1.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.recyclerview:recyclerview:1.1.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.vectordrawable:vectordrawable-animated:1.1.0, androidx.lifecycle:lifecycle-runtime:2.1.0, androidx.coordinatorlayout:coordinatorlayout:1.1.0, androidx.vectordrawable:vectordrawable:1.1.0, androidx.transition:transition:1.2.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.
后來檢查了一遍,原來是依賴的第三方開源庫使用了Androidx,導致專案報錯,
解決方法:在terminal中用
gradlew -q :app:dependencies
命令查看專案中依賴的第三方開源庫中的依賴項(app為模塊名),將有依賴于Androidx的第三方開源庫替換成依賴于support的庫就解決了
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/293647.html
標籤:其他
