Android模块化开发小demo
内置Android路由, 支持注解设置路由
如果你只想使用内置的Android路由模块,可以按照以下步骤完成。
在你的项目的build.gradle文件中添加一下代码:
dependencies {
// 默认配置
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
在你的lib的build.gradle中添加
apply plugin: 'com.neenbedankt.android-apt'
并且在dependencies中添加
compile 'org.loader:annotation:1.0.0'
compile 'org.loader:router:1.0.0'
apt 'org.loader:router-helper:1.0.0'
在lib项目中添加一个空类,并使用
@Component("libName")表示该lib的名称。
在需要注册路由的地方使用
@AutoRouter
或者
@StaticRouter(Scheme + "routerName")
进行路由注册
在壳工程的中添加如下配置:
apply plugin: 'com.neenbedankt.android-apt'
并在dependencies中添加
compile 'org.loader:annotation:1.0.0'
compile 'org.loader:router-helper:1.0.0'
apt 'org.loader:router-helper:1.0.0'
自定义Application,并且添加一下代码:
@Components({"components", "name"})
将上面定义的component的配置到这里。
在Application中调用如下代码,进行路由安装:
RouterHelper.install();
具体使用方式可以见该项目。