Mobile Development 12 min read

Android Componentization Architecture Practice in the Smart Train Ticket Project

This article describes how the Smart Train Ticket Android team adopted a componentization architecture—splitting base libraries and business modules, configuring independent and integrated builds, handling inter‑module communication, and solving manifest and multi‑flavor packaging challenges—to reduce coupling and dramatically improve build performance.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Android Componentization Architecture Practice in the Smart Train Ticket Project

Smart Train Ticket started as a train‑ticket service and expanded to include bus tickets, flights, and hotels, becoming an OTA platform. The original single‑module Android project faced issues such as heavy inter‑module coupling and long compilation times.

To address these problems, the team adopted a componentization architecture, extracting a base component library and independent business modules, enabling each module to be developed, compiled, and packaged separately.

The overall plan covered the reasons and goals of componentization, the steps for splitting base components and business modules, and the configuration needed for independent or integrated builds.

Base components were divided into business‑related AAR libraries (e.g., login, network) and source‑based libraries for frequently changing UI components. A shared

ext.libDefaultConfig = { minSdkVersion 19 targetSdkVersion 25 javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } } }

Gradle snippet ensures consistent SDK versions across libraries.

Business modules were extracted as independent libraries, with no direct dependencies between them. Build scripts toggle between apply plugin: 'com.android.application' for standalone execution and apply plugin: 'com.android.library' for integration, controlled by a single isSingleCompile = false flag.

Inter‑module communication is handled via a unified routing scheme (e.g., sy://suanya.cn/xxx?url=xxx&type=1) that supports native, web, and React‑Native pages, converting query parameters to ARouter calls when needed.

Challenges such as maintaining separate AndroidManifest files were solved with manifest‑merge rules, using tools:replace="android:theme,android:name," for the application node and tools:node="remove" for module‑only activities, allowing a single manifest source per module.

Multi‑application packaging was achieved with Gradle product flavors, allowing different app IDs, keys, themes, and signing configurations per flavor via

productFlavors.all { flavor -> signingConfigs.create(flavor.name, getSigningConfigsByFlavorName(flavor.name)) }

.

After componentization, code coupling was reduced, compilation time for a single module dropped to about 20 seconds, and full‑project build time fell to roughly one minute, significantly improving development efficiency.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AndroidBuild OptimizationGradleComponentizationmodular architecture
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.