TheRouter is a set of solution framework for Android modular development written in Kotlin and open sourced by Huolala Technology. It supports KSP and AGP8, which not only decouples conventional module dependencies and page jumps, but also provides solutions to common problems in the modularization process.
Github project address and usage documents are detailed in https://github.com/HuolalaTech/hll-wp-therouter-android.

Why use TheRouter


Routing is an indispensable function in mobile development today, especially for enterprise-level apps, which can be used to decouple the strong dependencies of Intent page jumps and reduce the interdependence of cross-team development.

For large-scale APP development, modular (or componentized) development is basically adopted, and the requirements for decoupling between modules are higher.

TheRouter is a complete set of solutions for modular development. It not only supports conventional module dependency decoupling and page jumping, but also provides solutions to common problems in the modularization process. For example: After modular development, the application life cycle and business process cannot be obtained in the component, which requires cross-module code modification for each initialization and associated dependency call.

TheRouter’s core functions have the following capabilities:

Navigator:

  • support Activity with Fragment
  • supportPathMany-to-one relationship or one-to-one relationship with pages can be used to solve the problem of multi-terminal path unification
  • pagePathSupport for regular expression declarations
  • support json format routing table export
  • Support dynamic distribution json Routing table, downgrade any page to H5
  • support anyobjectCross-module transfer (no need to serialize, and the object type can be guaranteed)
  • Support page jump interception processing
  • Supports custom page parameter parsing methods (for example, thejsonparsed as an object)
  • Support using routing to jump to the third-party SDKActivity(Fragment)

ServiceProvider:

  • Support cross-module dependency injection
  • Support the creation rules of custom injection items, dependency injection can customize parameters
  • Support custom service interception, single modulemockdebugging
  • Support for injecting object cache, multiple injections will only create new objects once

FlowTaskExecutor:

  • Support single module independent initialization
  • Support lazy loading initialization
  • Independent initialization allows multi-task dependencies (seeGradle Task)
  • Support compile-time circular reference detection
  • Support custom business initialization timing, which can be used to solve privacy compliance issues

ActionManager:

  • Support global callback configuration
  • Support priority response and interrupt response
  • Support recording call path, solve the problem that the observer mode cannot be tracked during debuggingObservableThe problem

Compared with other routes




















FunctionThe RouterARouterWMRouter
Fragment Routing✔️✔️✔️
dependency injection✔️✔️✔️
load routing tableNo runtime scanning
no reflection
Scan dex at runtime (new version changed to reflection)
reflection instance class
High performance loss
read file at runtime
reflection instance class
performance loss
Annotation regular expressions✔️✖️✔️
Activity specifies the interceptor✔️ (The four major interceptors can be customized according to the business)✖️✔️
Export route document✔️ (routing documents support adding comment descriptions)✔️✖️
Register routing information dynamically✔️✔️✖️
Support APT/KAPT incremental compilation✔️✔️ (Incremental compilation is not possible if document generation is turned on)✖️
Support KSP compilation✔️✖️✖️
Support AGP8✔️Not available after Gradle 7.3Not available after Gradle 7.3
plugin supports incremental compilation✔️✖️✖️
Multiple Paths correspond to the same page (low cost to realize the unification of double-ended paths)✔️✖️✖️
Remote routing table delivery✔️✖️✖️
Support single module independent initialization✔️✖️✖️
Support using routing to open third-party SDK pages✔️✖️✖️
support for hotfixes (e.g. tinker)✔️(unchanged code builds multiple times without changes)✖️(Multiple builds of apt products will change, generating meaningless patches)✖️(Multiple builds of apt products will change, generating meaningless patches)

#TheRouter #Homepage #Documentation #Downloads #Android #Modular #Development #Solution #Framework #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *