由于一些很坑的原因,导致提供的aar需要从androidx框架回退到旧的support库,通过androidx关键字删除了代码中所有的依赖后,编译还是报了错误,显示还有依赖androidx的地方。
Caused by: com.android.builder.errors.EvalIssueException: 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.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.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
使用命令:gradle -q :app:dependencies
可以查看模块app
的所有依赖树。
debugAnnotationProcessorClasspath - Resolved configuration for annotation-processor for variant: debug
\--- com.github.hotchemi:permissionsdispatcher-processor:4.1.0
+--- org.jetbrains.kotlin:kotlin-stdlib:1.2.71
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.2.71
| \--- org.jetbrains:annotations:13.0
+--- com.squareup:javapoet:1.9.0
+--- com.squareup:kotlinpoet:1.0.0-RC1
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.50
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.50 -> 1.2.71 (*)
| \--- org.jetbrains.kotlin:kotlin-reflect:1.2.50
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.50 -> 1.2.71 (*)
+--- com.github.hotchemi:permissionsdispatcher-annotation:4.1.0
\--- androidx.annotation:annotation:1.0.0
分析上面的输出,发现工程依赖的三方库里存在androidx的依赖。查阅官网文档,得知permissionsdispatcher
自4.x
以后只支持Jetpack。遂改为3.3.1
,重新编译,问题解决!
【参考资料】
Android将Androidx项目回退到support项目
Andorid开发,support 迁移androidx,或androidx回退androidx 对比
PermissionsDispatcher