新手小白使用ARouter犯的错,如下所示:
关键的信息就是:
Type com.alibaba.android.arouter.routes.ARouter$$Group$$xxx is defined multiple times
经过搜索后,发现出现这个原因就是不同的模块的路由地址前缀相同了,具体来看我的错误写法:
1、public static final String ROUTER_HOME_PRESET_PATH = "/app/home/preset"; // 主页模块的路由地址1
2、public static final String ROUTER_HOME_CUSTOM_PATH = "/app/home/custom"; // 主页模块的路由地址2
3、public static final String ROUTER_EDIT_PATH = "/app/edit/activity"; // 编辑模块的Activity路由地址
4、public static final String ROUTER_EDIT_BOTTOM_TOOLBAR_PATH = "/app/edit/bottom_toolbar/fragment"; // 底部操作栏模块地址
首先同一个模块下,路由地址的前缀是可以相同的,例如1、2中的地址,公共前缀/app/
由于编辑模块和底部操作栏模块是两个单独的module,所以不能携带任何公共前缀 /app
更改如下:
public static final String ROUTER_HOME_PRESET_PATH = "/home/preset";
public static final String ROUTER_HOME_CUSTOM_PATH = "/home/custom";
public static final String ROUTER_EDIT_PATH = "/edit/activity";
public static final String ROUTER_EDIT_BOTTOM_TOOLBAR_PATH = "/bottom_toolbar/fragment";
而且还要注意,路由地址至少2级起步。不能单独写个 :/preset、/custom。这种是不行的哦