跪拜 Guibai
← All articles
Android · Kotlin · Open Source

ViewCompose Brings Declarative UI to Native Android Views

By 小强闯江湖 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Android teams with heavy investments in the View system can now adopt a modern, state-driven development model without a binary rewrite into Compose. ViewCompose absorbs the cross-cutting concerns of state sync, partial refresh, and lifecycle management that traditionally scatter across Activities and Adapters, while preserving direct access to the mature View component ecosystem.

Summary

ViewCompose offers a third path for Android UI, separating the declarative description of an interface from its rendering engine. Developers write composable, state-driven Kotlin code, and the framework handles diffing, patching, and transactional commits to produce a standard Android View hierarchy. This means teams can modernize their development model without abandoning the View ecosystem's maturity, accessibility support, and third-party component compatibility. The project ships as 38 Maven modules across five strict architectural layers, from a pure-Kotlin kernel to design systems and integrations for Coil, CameraX, and Maps. It includes its own preview tooling, diagnostics, and a rigorous documentation system that enforces compilable samples and API quality levels. Still in Alpha, it targets teams with large View codebases who need declarative productivity without the risk of a full Compose rewrite.

Takeaways
ViewCompose generates a real Android View tree from a declarative Kotlin DSL, making it a native-View framework, not a Compose compatibility layer.
The framework runtime handles state observation, diffing, patching, and transactional commits, removing the need for manual refresh chains in business code.
A strict five-layer architecture prevents AndroidX, Material, or design-system specifics from leaking into the pure-Kotlin core or the rendering engine.
The project ships 38 public Maven modules, including integrations for Coil, Glide, CameraX, Google Maps, Media3, and ConstraintLayout.
Documentation is treated as a first-class deliverable, with mandatory KDoc quality levels, compilable `@sample` references, and build failures for undocumented public APIs.
ViewCompose does not depend on the Compose Compiler plugin; it uses its own `ComposerLite` and `SlotTable` for incremental composition.
It remains in Alpha, with API convergence, device-matrix validation, and ecosystem growth still in progress.
Conclusions

ViewCompose reframes the Android UI debate from a tooling choice to an architectural one, absorbing state management and lifecycle concerns that most View-based projects solve with ad-hoc patterns.

The framework's strict module layering and build gates against dependency leakage are unusually disciplined for an Alpha-stage project, suggesting a design optimized for long-term maintainability over short-term convenience.

By not depending on the Compose Compiler, ViewCompose avoids a major build-time dependency but also forfeits Compose's automatic stability inference, pushing more optimization responsibility onto the developer.

Treating documentation as a build-failing artifact with compilable samples is a high-cost, high-signal strategy that directly addresses the maintenance knowledge gap that plagues many internal frameworks.

Concepts & terms
VNode / NodeSpec
Immutable data structures in ViewCompose that represent component semantics and the UI tree. They enable the framework to diff and patch only the changed parts of a View hierarchy, similar to how a virtual DOM operates.
ComposerLite / SlotTable
ViewCompose's own incremental composition engine, used instead of the Compose Compiler. It tracks state reads and manages a slot-based table to determine which parts of the UI need to be re-executed when state changes.
Transactional native tree updates
A rendering model where View tree mutations are prepared, applied, and then either committed or rolled back as a unit. Irreversible side effects are deferred to an `onCommit` phase, preventing half-finished UI states from being visible.
From the discussion
Featured comments
kosm0s 1 likes

1. What does this mean? Compose can already seamlessly embed View components. Declarative UI on Android also started from View originally, and then moved to Compose because of too many limitations. How is it that things are going backwards now? [facepalm] Are you just starting to learn Android? The big front-end era is over. The players left in this track all have n number of projects. There's Anko for lightweight DSL, Kuikly for mature enterprise-level, RN, uniapp-x, etc. for a web development experience. And Compose's latest performance is already slightly higher than native benchmarks.

小强闯江湖

Use it or not, it's up to you. For me, this was an experience managing a large-scale project and incidentally producing an output. Compose is still the first recommendation. Of course, this project also has its advantages, such as being able to fully reuse decades of accumulation in the Android View system, like stability, accessibility, and so on. Also, in cold starts and some other scenarios, this project's performance is better than Compose. If you're interested, you can check the 'Performance' section in the project documentation (https://docs.viewcompose.com/zh-CN/tooling/performance/), which has detailed benchmark conclusions and an optimization timeline.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗