这里需要有几点说明一下:1,通过 isModule.toBoolean() 方法 方法来进行组件间集成模式和组件模式的切换包括模块是属于Application 还是 Library由于集成了 ARouter所以需要对 ARouter 配置文件进行处理。2如果组件模式下 则需要重新设置 AndroidManifest.xml 文件里面配置新的Application路径。比如Login组件单独运行 AndroidManifest 清单文件manifest xmlns:androidhttp://schemas.android.com/apk/res/android packagehik.ga.business.applogin application android:namedebug.LoginApplication android:allowBackupfalse android:iconmipmap/ic_launcher android:labelstring/login_btn_str android:supportsRtltrue android:themestyle/Theme.AppCompat.Light.NoActionBar activity android:namehik.ga.business.applogin.login.views.LoginActivity android:labelstring/login_btn_str android:launchModesingleTop android:screenOrientationportrait android:themestyle/AppTheme.NoActionBarFullScreen intent-filter action android:nameandroid.intent.action.MAIN / category android:nameandroid.intent.category.LAUNCHER / /intent-filter /activity /application /manifest3实现组件全局应用配置类这个类的目的是在组件加载时初始化一些组件自身的资源如下public class LoginApplicationDelegate implements IApplicationDelegate { private static final String TAG LoginApplicationDelegate; Override public void onCreate() { EFLog.d(TAG, *------------------onCreate()----------------); } Override public void enterBackground() { EFLog.d(TAG, *------------------enterBackground()----------------); } Override public void enterForeground() { EFLog.d(TAG, *------------------enterForeground()----------------); } Override public void receiveRemoteNotification(MapString, String message) { EFLog.d(TAG, receiveRemoteNotification msg message); } Override public void onTerminate() { EFLog.d(TAG, *------------------onTerminate()----------------); } Override public void onConfigurationChanged(Configuration configuration) { EFLog.d(TAG, *------------------onConfigurationChanged()----------------); } Override public void onLowMemory() { EFLog.d(TAG, *------------------onLowMemory()----------------); } Override public void onTrimMemory(int var1) { EFLog.d(TAG, *------------------onTrimMemory()----------------); } }三路由服务1定义公共组件路由API和入口通过路由服务组件查找如图2组件路由实现每个组件对外提供什么能力首先需要在路由服务组件创建一个接口文件如下是登陆组件接口声明和实现。Login 接口具体实现路由使用比如我们想从设置页面跳转到登陆页面使用 Login 接口里的方法使用如下ILoginProvider loginService (ILoginProvider) ARouter.getInstance().build(RouterPath.ROUTER_PATH_TO_LOGIN_SERVICE).navigation(); if(loginService ! null){ loginService.accountToLogin(AccountActivity.this); }