ARouter
ARouter copied to clipboard
一个笨方法兼容androidx的方式
- 把ARouter源码下载下来。(我目前使用 1.4版本)进行依赖到项目中
- 替换 v4、v7包。替换成androidx (support包主要在arouter-api中)
替换掉build.gradle下面的依赖
替换成 androidx
替换成 androidx
arouter-compiler下的Consts.java
替换成 androidx
arouter-api build.gradle
配置:
arouter-annotation build.gradle
配置:
arouter-compiler build.gradle
配置:
首先我声明一点 在导入“annotationProcessor”时,不能只写 “project(':arouter-compiler')”
必须要这样写。我也不知道问什么。只知道这样写可以运行。
求知道原理的大佬在下面进行留言。
目前我用的 1.4.1版本的路由 所以compiler版本为:1.2.0.(官方源码里对应的版本)
使用时:
annotationProcessor project(':arouter-compiler')
annotationProcessor 'com.alibaba:arouter-compiler:1.2.0'
api project(':arouter-annotation')
目前 测试 androidx 通过运行。
再次声明
我不清楚 为什么必须要写2个注册。
求知道原理的大佬在下面进行留言。
gradle.properties里加这两行就得了
android.useAndroidX=true
Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
有才啊