1. 程式人生 > >ARouter::There is no route match the path

ARouter::There is no route match the path

ARouter:https://github.com/alibaba/ARouter
在使用服務時會提示找不到路由路徑,但是已經按照官網提示的配置好了路徑。
原因:可能是配置出現問題。

在模組化開發時需要在各個模組的build.gradle裡都要配置

defaultConfig {
        ...

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [moduleName: project.getName()]
            }
        }

    }


dependencies {
    ...

    annotationProcessor 'com.alibaba:arouter-compiler:1.1.4'
    implementation project(':base')//base模組裡新增依賴

}

同時base模組裡

dependencies {
   ...
    compile ('com.alibaba:arouter-api:1.3.1'){ exclude group: 'com.android.support' }
//    implementation 'com.alibaba:arouter-api:1.3.1'

}

注意:匯入arouter-api時可能出現V4包版本不一致,如下異常,所以將其遮蔽

Error:Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (25.2.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

雖然編譯沒有問題,但是在執行時可能出現異常

com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/alibaba/android/arouter/routes/ARouter$$Group$$user;

解決方法:https://blog.csdn.net/baidu_21345205/article/details/80360014