今天使用阿里巴巴的Arouter路由框架开发的时候,遇到:ARouter::Compiler >>> No module name, for more information, look at gradle log.
这里记录一下起因和解决方案。
1、在每一个moudle中想要使用路由跳转的话,加上这段代码:
android {
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
}
2、在每一个moudle中想要使用路由跳转的话,加上这段代码:
annotationProcessor'com.alibaba:arouter-compiler:1.2.2'
3、在基础的moudle中加上这句代码
api'com.alibaba:arouter-api:1.4.1' 这个必须要加
annotationProcessor'com.alibaba:arouter-compiler:1.2.2'
还有一个问题:
"W/ARouter::: ARouter::There is no route match the path [/xxx/xxx], in group [xxx][ ]"。
通常来说这种情况是没有找到目标页面,目标不存在
如果这个页面是存在的,那么您可以按照下面的步骤进行排查
检查目标页面的注解是否配置正确,正确的注解形式应该是 (@Route(path="/test/test"), 如没有特殊需求,请勿指定group字段,废弃功能)
我这个问题比较奇葩:一级路径都是test就不行,一级路径不一样才可以,如下: test/ findName/
PS:还有,'com.alibaba:arouter-compiler:x.x.x' 'com.alibaba:arouter-api:x.x.x' 要使用最新的版本