Skip to content

Releases: donglua/LayoutX2C

1.4.0

23 Jun 02:02

Choose a tag to compare

中文

新增

  • 为业务自定义 View / ViewFactory 生成 synthetic AttributeSet,保留 XML 中的 android/app 属性名称、原始值和资源 ID。
  • 新增 layoutX2C.enableSyntheticAttributeSet 开关,必要时可关闭 synthetic attrs 生成。
  • Demo 增加自定义属性示例,并用真机 instrumentation 覆盖 ViewFactory 读取 synthetic attrs 的路径。

修复

  • 默认生成的自定义 View 构造器恢复为 View(context),避免把普通 Java/Kotlin AttributeSet 传入 Android View(context, attrs) 后触发 XmlBlock.Parser 强转崩溃。
  • synthetic attrs 仅传给 ViewFactory hook 做原始 AttributeSet 查询;已声明的安全属性继续通过 typed setter 重放。

验证

  • ./gradlew check
  • ./gradlew test :demo:assembleDebug :runtime:assembleRelease :demo:assembleRelease :demo:assembleDebugAndroidTest
  • 真机 adb install + am instrument,41 个 instrumentation tests 全部通过。

兼容性

  • 无破坏性变更。

English

Added

  • Generate synthetic AttributeSet metadata for business custom Views and ViewFactory hooks, preserving android/app attribute names, raw values, and resource IDs from XML.
  • Add the layoutX2C.enableSyntheticAttributeSet option to disable synthetic attrs generation when needed.
  • Add a demo custom-attribute layout and device instrumentation coverage for ViewFactory synthetic attrs inspection.

Fixed

  • Keep generated custom-view default constructors on View(context) so Android does not crash by casting a plain Java/Kotlin AttributeSet to its internal XmlBlock.Parser.
  • Limit synthetic attrs to ViewFactory hook raw AttributeSet inspection; declared safe custom attributes continue to be replayed through typed setters.

Verified

  • ./gradlew check
  • ./gradlew test :demo:assembleDebug :runtime:assembleRelease :demo:assembleRelease :demo:assembleDebugAndroidTest
  • Real-device adb install + am instrument, all 41 instrumentation tests passed.

Compatibility

  • No breaking changes.

1.3.0

22 Jun 06:16

Choose a tag to compare

LayoutX2C 1.3.0

中文

LayoutX2C 1.3.0 是 1.2.0 之后的兼容 minor 版本,新增自定义 View 创建扩展点。它让生成代码在创建业务自定义 View 时,可以先交给运行时注册的 ViewFactory,用于接入换肤框架、自定义 View 替换或业务侧 View 创建策略。

这个版本不引入 breaking change。未注册 ViewFactory,或 ViewFactory 返回 null 时,生成代码继续使用默认构造函数创建 View。

主要变化

  • 新增 ViewFactory 接口,允许业务侧按 XML tag name 接管自定义 View 创建。
  • 新增 ViewFactoryRegistry,支持运行时注册和重置 View 创建工厂。
  • 新增 ViewFactoryCompat,供生成代码统一调用自定义 View 创建 hook。
  • cn.xxxcom.example.xxx 等非 framework 全限定名 View,生成代码会先尝试 ViewFactoryCompat.createView(...)
  • 普通 android.*androidx.*、Material 控件继续走原有直接构造路径,避免影响已验证的平台控件语义。
  • README 新增运行时扩展点说明,覆盖 ResourceLoaderViewFactory 的用法与边界。

接入方式

plugins {
    id("io.github.donglua.layoutx2c") version "1.3.0"
}

手动依赖配置:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.3.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.3.0")
}

自定义 View 创建 hook:

ViewFactoryRegistry.setViewFactory { context, name, attrs ->
    when (name) {
        "com.example.widget.PriceView" -> PriceView(context, attrs)
        else -> null
    }
}

已知边界

  • 当前生成路径不会重放平台 XML parser,因此传给 ViewFactoryattrs 可能为 null
  • 强依赖非空 AttributeSet 的第三方 inflater,应在 attrs == null 时返回 null,避免破坏默认创建路径。
  • 完全等价复用强依赖 AttributeSet 的 inflater,还需要后续 synthetic AttributeSet 支持。

English

LayoutX2C 1.3.0 is a compatible minor release after 1.2.0. It adds a custom View creation extension point so generated code can delegate business custom View creation to a runtime-registered ViewFactory before falling back to the default constructor.

This release does not introduce breaking changes. If no ViewFactory is registered, or if the registered factory returns null, generated code keeps using the default View constructor.

Highlights

  • Added the ViewFactory interface for custom View creation by XML tag name.
  • Added ViewFactoryRegistry to install and reset the runtime View factory.
  • Added ViewFactoryCompat as the generated-code entry point for custom View creation hooks.
  • Generated code now tries ViewFactoryCompat.createView(...) for non-framework fully qualified View names such as cn.xxx and com.example.xxx.
  • Platform and framework widgets such as android.*, androidx.*, and Material components keep the existing direct-constructor path.
  • Updated README runtime extension documentation for ResourceLoader and ViewFactory.

Setup

plugins {
    id("io.github.donglua.layoutx2c") version "1.3.0"
}

Manual dependency setup:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.3.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.3.0")
}

Custom View creation hook:

ViewFactoryRegistry.setViewFactory { context, name, attrs ->
    when (name) {
        "com.example.widget.PriceView" -> PriceView(context, attrs)
        else -> null
    }
}

Known boundaries

  • The generated path does not replay the platform XML parser yet, so attrs passed to ViewFactory may be null.
  • Third-party inflaters that require a non-null AttributeSet should return null when attrs == null, preserving the default creation path.
  • Fully equivalent reuse of AttributeSet-dependent inflaters requires future synthetic AttributeSet support.

1.2.0

22 Jun 02:43

Choose a tag to compare

LayoutX2C 1.2.0

中文

LayoutX2C 1.2.0 是 1.1.1 之后的兼容 minor 版本,重点加入生成代码可复用的资源加载入口,让换肤框架或自定义资源系统可以接管颜色、drawable、ColorStateList、dimension 和 string 的读取。

这个版本不引入 breaking change。默认实现仍然委托给 AndroidX ContextCompat 和系统 Resources,未配置自定义 loader 时行为保持和 1.1.1 一致。

主要变化

  • 新增 ResourceLoader 接口,覆盖 color、ColorStateList、drawable、dimension 和 string 资源读取。
  • 新增 ResourceLoaderRegistry,支持运行时设置或重置全局资源加载器。
  • 新增 ResourceCompat 公共入口,供生成代码调用当前注册的资源加载器。
  • 生成代码中的资源读取从直接调用 AndroidX ContextCompat 切换为 ResourceCompat
  • 补充资源加载器 androidTest,覆盖默认实现、自定义 loader 和 reset 行为。
  • 调整 codegen / KSP 测试断言,验证生成代码引用新的 ResourceCompat 入口。

接入方式

plugins {
    id("io.github.donglua.layoutx2c") version "1.2.0"
}

手动依赖配置:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.2.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.2.0")
}

换肤框架可以在应用初始化时注册自定义资源加载器:

ResourceLoaderRegistry.setResourceLoader(customResourceLoader)

发布坐标:

  • io.github.donglua.layoutx2c:runtime:1.2.0
  • io.github.donglua.layoutx2c:compiler-core:1.2.0
  • io.github.donglua.layoutx2c:ksp-processor:1.2.0
  • io.github.donglua.layoutx2c:gradle-plugin:1.2.0
  • Gradle plugin id:io.github.donglua.layoutx2c

已知边界

  • ResourceLoaderRegistry 是进程级全局入口,测试或多主题场景应在用例结束后调用 reset()
  • 自定义 loader 只影响 LayoutX2C 生成代码经过 ResourceCompat 的资源读取,不会改变原生 LayoutInflater fallback 路径。
  • 未支持的 View 类或不安全属性仍会 fallback 到平台 inflation。

English

LayoutX2C 1.2.0 is a compatible minor release after 1.1.1. It adds a generated-code resource loading entry point so skinning frameworks or custom resource systems can intercept color, drawable, ColorStateList, dimension, and string reads.

This release does not introduce breaking changes. The default implementation still delegates to AndroidX ContextCompat and platform Resources, so behavior stays aligned with 1.1.1 unless a custom loader is registered.

Highlights

  • Added the ResourceLoader interface for color, ColorStateList, drawable, dimension, and string resource reads.
  • Added ResourceLoaderRegistry to install or reset the process-wide resource loader at runtime.
  • Added the public ResourceCompat entry point used by generated code.
  • Switched generated resource reads from direct AndroidX ContextCompat calls to ResourceCompat.
  • Added androidTest coverage for the default loader, custom loaders, and reset behavior.
  • Updated codegen / KSP assertions to verify generated code references the new ResourceCompat entry point.

Setup

plugins {
    id("io.github.donglua.layoutx2c") version "1.2.0"
}

Manual dependency setup:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.2.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.2.0")
}

Skinning frameworks can register a custom loader during app startup:

ResourceLoaderRegistry.setResourceLoader(customResourceLoader)

Published coordinates:

  • io.github.donglua.layoutx2c:runtime:1.2.0
  • io.github.donglua.layoutx2c:compiler-core:1.2.0
  • io.github.donglua.layoutx2c:ksp-processor:1.2.0
  • io.github.donglua.layoutx2c:gradle-plugin:1.2.0
  • Gradle plugin id: io.github.donglua.layoutx2c

Known boundaries

  • ResourceLoaderRegistry is process-wide, so tests or multi-theme scenarios should call reset() after use.
  • Custom loaders affect only LayoutX2C generated code paths that read resources through ResourceCompat; native LayoutInflater fallback paths are unchanged.
  • Unsupported View classes or unsafe attributes still fall back to platform inflation.

1.1.1

17 Jun 09:56

Choose a tag to compare

LayoutX2C 1.1.1

🐛 Bug Fixes

DataBinding ImageView src attribute support

Problem: When using android:src="@{icon}" with DataBinding, the icon was not displayed because the binding code was not being generated.

Root Cause: The ImageSourceAttributeHandler.supportsValue() method rejected DataBinding expressions like "@{icon}" because isSupportedDrawableReference() returned false. This caused android:src to be marked as 'unsupported' instead of 'dataBinding', preventing the binding code from being generated in executeBindings().

Solution: Modified ImageSourceAttributeHandler.supportsValue() to accept DataBinding expressions (@{} and @={}). DataBinding expressions are now validated at runtime via executeBindings() rather than at compile time.

Impact:

  • android:src="@{icon}" now correctly generates viewIcon.setImageResource(icon ?: 0)
  • ✅ Static drawable references (@drawable/xxx) continue to work
  • ✅ Theme attribute references (?attr/xxx) continue to work

📝 Changes

Commits

  • cbcb2aa fix: support DataBinding expressions in ImageView android:src attribute
  • 7894da7 test: fix ImageViewSrcBindingTest array index out of bounds
  • 697d204 docs(release): split 1.1.0 notes by language
  • 5c9a49e docs(release): polish 1.1.0 notes

Modified Files

  • compiler-core/src/main/kotlin/com/github/donglua/layoutx2c/registry/ViewRegistry.kt
  • compiler-core/src/test/kotlin/com/github/donglua/layoutx2c/codegen/ImageViewSrcBindingTest.kt
  • Release documentation improvements

📦 Installation

Gradle (Kotlin DSL)

dependencies {
    ksp("com.github.donglua:layoutx2c-ksp:1.1.1")
    implementation("com.github.donglua:layoutx2c-runtime:1.1.1")
}

Gradle (Groovy)

dependencies {
    ksp 'com.github.donglua:layoutx2c-ksp:1.1.1'
    implementation 'com.github.donglua:layoutx2c-runtime:1.1.1'
}

🔍 How to Verify

After updating to 1.1.1 and rebuilding your project, check the generated binding code:

Before (1.1.0):

protected override fun executeBindings() {
    if (dirtyFlags != 0L) {
        viewText.setText(text ?: "")
        // ❌ Missing: viewIcon.setImageResource(icon ?: 0)
    }
}

After (1.1.1):

protected override fun executeBindings() {
    if (dirtyFlags != 0L) {
        viewText.setText(text ?: "")
        viewIcon.setImageResource(icon ?: 0)  // ✅ Now generated
    }
}

📖 Full Changelog

v1.1.0...v1.1.1

1.1.0...1.1.1

1.1.0

14 Jun 08:28

Choose a tag to compare

LayoutX2C 1.1.0

中文

LayoutX2C 1.1.0 是 1.0 稳定版之后的第一个 minor 版本,重点扩展安全可生成属性、修复 DataBinding / BindingAdapter 边界问题,并增强资源追踪和发布验证。

这个版本继续保持 1.0 的保守契约:可静态确认等价的 XML 会进入生成代码,不支持或无法确认等价的平台语义继续走原生 LayoutInflater、原生 DataBinding 或 fallback path。1.1.0 不引入 breaking change。

主要变化

  • 扩展常用 View 属性支持,包括 transform、EditText 常用属性、view state、scrollbar / over-scroll 和 accessibility importance 等安全子集。
  • 支持可静态解析的 theme drawable attrs,在保持平台 inflation 语义等价的前提下减少 fallback。
  • 修复 malformed DataBinding include 处理,避免生成无效 binding facade code。
  • 修复 DataBinding include / root 字段绑定路径,保持 include root ID 和 binding 字段语义一致。
  • 补齐 BindingAdapter config generation、unsupported expression 和 unprefixed fast binding attrs 等路径覆盖。
  • qualified layout resources 已进入 resource digest tracking,layout 变体和 values qualifier 会参与 cache / regeneration 判断。
  • ConstraintLayout Guideline 参数保留已补齐,并加入 demo equivalence coverage。
  • 新增 Kover / Codecov CI 上报,补充 registry、dimension、fallback path、plugin provider 和 report task 等覆盖。
  • 新增 fallback performance notes,明确 full-tree extraction、batched extraction,以及不采用 partial XmlPullParser inflate / native hook 的原因。

从 1.0.0 到 1.1.0

  • 新增 transform / EditText / view state / theme drawable attrs 的安全生成能力。
  • 改进 DataBinding include 和 BindingAdapter 的生成边界,遇到不安全结构时更保守地 fallback。
  • 改进 layout resource digest,避免 qualified resources 或 values 变体变化时复用过期生成结果。
  • 补充 generated-vs-inflated 等价性测试,覆盖 TextView、ImageView、RelativeLayout、EditText、view state 和 Guideline 场景。
  • 强化 CI 覆盖率上报和报告任务测试,便于持续观察 fallback 和生成质量。
  • 记录 fallback 性能边界,避免重新引入不安全的 runtime partial inflate 方案。

兼容信息

  • Minimum SDK:23
  • Compile SDK:36
  • Target SDK:36
  • Android Gradle Plugin:9.2.1
  • Kotlin:2.2.21
  • KSP:2.3.8
  • Java source / target compatibility:11
  • Release build toolchain:JDK 21

接入方式

plugins {
    id("io.github.donglua.layoutx2c") version "1.1.0"
}

手动依赖配置:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.1.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.1.0")
}

发布坐标:

  • io.github.donglua.layoutx2c:runtime:1.1.0
  • io.github.donglua.layoutx2c:compiler-core:1.1.0
  • io.github.donglua.layoutx2c:ksp-processor:1.1.0
  • io.github.donglua.layoutx2c:gradle-plugin:1.1.0
  • Gradle plugin id:io.github.donglua.layoutx2c

已知边界

  • 未支持的 View 类或不安全属性仍会 fallback 到平台 inflation。
  • 动态 theme 语义不会默认编译成常量,?attr/ 等运行时主题能力仍保持保守处理。
  • DataBinding 支持仍是有边界的。LayoutX2C 不替代完整原生 DataBinding runtime、复杂表达式引擎、Observable / LiveData 订阅模型或 lifecycle 分发。
  • 自定义 View 和 BindingAdapter 只有显式加入白名单后才会进入生成代码。
  • :demo:connectedDebugAndroidTest 建议在有设备或 CI emulator 的环境中补跑,用于验证真实 Android runtime 下的 generated-vs-inflated 等价性。

English

LayoutX2C 1.1.0 is the first minor release after the 1.0 stable release. It expands safe attribute generation, fixes DataBinding / BindingAdapter boundary cases, and improves resource tracking and release verification.

This release keeps the 1.0 conservative contract: XML that can be statically proven equivalent is generated into code, while unsupported or unsafe platform semantics continue to use native LayoutInflater, native DataBinding, or the fallback path. 1.1.0 does not introduce breaking changes.

Highlights

  • Expanded common View attribute support, including safe subsets for transform, common EditText attributes, view state, scrollbar / over-scroll, and accessibility importance.
  • Added support for statically resolvable theme drawable attrs when the generated path can preserve platform inflation semantics.
  • Fixed malformed DataBinding include handling so invalid structures do not generate invalid binding facade code.
  • Fixed DataBinding include / root field binding paths so include root IDs and binding fields stay consistent.
  • Added coverage for BindingAdapter config generation, unsupported expressions, and unprefixed fast binding attrs.
  • Added qualified layout resources to resource digest tracking, so layout variants and values qualifiers participate in cache / regeneration decisions.
  • Preserved ConstraintLayout Guideline params in generated code and added demo equivalence coverage.
  • Added Kover / Codecov CI reporting and expanded coverage for registry, dimension, fallback path, plugin provider, and report task behavior.
  • Added fallback performance notes covering full-tree extraction, batched extraction, and why partial XmlPullParser inflate / native hooks are not used.

Changes since 1.0.0

  • Added safe generation support for transform / EditText / view state / theme drawable attrs.
  • Improved DataBinding include and BindingAdapter generation boundaries, with more conservative fallback for unsafe structures.
  • Improved layout resource digests to avoid reusing stale generated outputs when qualified resources or values variants change.
  • Expanded generated-vs-inflated equivalence tests for TextView, ImageView, RelativeLayout, EditText, view state, and Guideline cases.
  • Hardened CI coverage reporting and report task tests for ongoing fallback and generation quality checks.
  • Documented fallback performance boundaries to avoid reintroducing unsafe runtime partial-inflate approaches.

Compatibility

  • Minimum SDK: 23
  • Compile SDK: 36
  • Target SDK: 36
  • Android Gradle Plugin: 9.2.1
  • Kotlin: 2.2.21
  • KSP: 2.3.8
  • Java source / target compatibility: 11
  • Release build toolchain: JDK 21

Setup

plugins {
    id("io.github.donglua.layoutx2c") version "1.1.0"
}

Manual dependency setup:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.1.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.1.0")
}

Published coordinates:

  • io.github.donglua.layoutx2c:runtime:1.1.0
  • io.github.donglua.layoutx2c:compiler-core:1.1.0
  • io.github.donglua.layoutx2c:ksp-processor:1.1.0
  • io.github.donglua.layoutx2c:gradle-plugin:1.1.0
  • Gradle plugin id: io.github.donglua.layoutx2c

Known boundaries

  • Unsupported View classes or unsafe attributes still fall back to platform inflation.
  • Dynamic theme semantics are not compiled into constants by default. Runtime theme features such as ?attr/ remain conservative.
  • DataBinding support is intentionally scoped. LayoutX2C does not replace the full native DataBinding runtime, complex expression engine, Observable / LiveData subscription model, or lifecycle dispatch.
  • Custom views and BindingAdapters only enter generated code when explicitly whitelisted.
  • :demo:connectedDebugAndroidTest should still be run in an environment with a device or CI emulator to verify generated-vs-inflated equivalence on a real Android runtime.

1.0.0

08 Jun 00:43

Choose a tag to compare

LayoutX2C 1.0.0

中文

LayoutX2C 1.0.0 是首个稳定版本,提供编译期 Android XML Layout 到 Kotlin 代码的生成流程。

1.0 的核心约束是保守生成:支持的 XML 进入生成代码,不支持或无法确认等价的语义继续走平台 inflation,未支持的布局不应导致应用构建失败。这个版本适用于需要把热点 XML 布局 inflation 移到生成代码、但仍保留 Android 资源解析、主题系统、DataBinding 运行时和平台 LayoutInflater 行为的项目。

主要变化

  • 稳定运行时 API 边界,使用 @PublicApi@ExperimentalApi 区分兼容承诺。
  • 提供 Android application 和 library 模块可用的 Gradle 插件,自动配置 KSP、runtime 依赖和 processor 参数。
  • 支持通过 @FastLayoutConfig@FastLayouts@FastLayoutPattern 发现待生成布局。
  • 提供 per-layout JSON 报告,以及项目级 layoutX2CReport HTML / JSON 汇总,便于在本地和 CI 中查看 fallback 情况。
  • 对未支持节点、未支持属性、<include>ViewStub 和 DataBinding 语义保持保守 fallback。
  • 增量生成缓存按 layout 和资源依赖 digest 计算,覆盖递归 include 布局和引用到的 values 资源。
  • 支持常见 Android / AndroidX View、ConstraintLayout 安全子集、style、资源引用、白名单自定义 View 和白名单 BindingAdapter 的静态生成。

从 0.4.1 到 1.0.0

  • 增加稳定 public runtime API,作为 1.0 兼容契约的基础。
  • 扩展 Text / View 展示属性、常见 widgets、容器、app bar、ScrollView / ImageView 组合,以及 ConstraintLayout 参数生成能力,包括 Guideline 和常见 chain 语义。
  • 增加 @FastCustomViews 白名单自定义 View 生成能力,并支持识别继承自已支持平台容器的自定义 View。
  • 增加白名单 DataBinding BindingAdapter 生成能力,并补齐 include、嵌套 include、生成字段、root 字段、变量、pending-binding 状态和部分双向绑定的 binding facade 支持。
  • 改进 fallback 性能:批量处理 sibling / subtree fallback inflation,并缓存缺失的生成 registry 查询结果。
  • 改进 codegen 性能:复用生成 factory 引用,减少重复 layout params 配置。
  • 改进资源解析:支持 AGP resource symbol 文件、外部 R jar 和精确资源依赖 hash。
  • 增加 Android 等价性覆盖,包含生成 inflate 行为、ViewStub、DataBinding、显式 View 属性、兼容 widgets 和 demo gallery 流程。
  • 强化发布流程,支持 Maven Central GPG command signing 和 Central Portal bundle。

兼容信息

  • Minimum SDK:23
  • Compile SDK:36
  • Target SDK:36
  • Android Gradle Plugin:9.2.1
  • Kotlin:2.2.21
  • KSP:2.3.8
  • Java source / target compatibility:11
  • Release build toolchain:JDK 21

接入方式

plugins {
    id("io.github.donglua.layoutx2c") version "1.0.0"
}

手动依赖配置:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.0.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.0.0")
}

发布坐标:

  • io.github.donglua.layoutx2c:runtime:1.0.0
  • io.github.donglua.layoutx2c:compiler-core:1.0.0
  • io.github.donglua.layoutx2c:ksp-processor:1.0.0
  • io.github.donglua.layoutx2c:gradle-plugin:1.0.0
  • Gradle plugin id:io.github.donglua.layoutx2c

已知边界

  • 未支持的 View 类或不安全属性仍会 fallback 到平台 inflation。
  • RecyclerView 和 ViewPager2 只生成容器本身,adapter 和运行时行为仍由应用负责。
  • DataBinding 支持是有边界的。LayoutX2C 不替代完整原生 DataBinding 运行时、表达式引擎、observable 订阅模型或 lifecycle 分发。
  • 自定义 View 和 BindingAdapter 只有显式加入白名单后才会进入生成代码。

English

LayoutX2C 1.0.0 is the first stable release of the compile-time Android XML layout to Kotlin generation pipeline.

The 1.0 contract is intentionally conservative: supported XML is generated into code, unsupported or unsafe semantics continue to use platform inflation, and unsupported layouts should not break application builds. This release is meant for projects that want to move hot XML layout inflation paths to generated code while keeping Android resource resolution, theming, DataBinding runtime behavior, and platform LayoutInflater semantics intact.

Highlights

  • Stable runtime-facing API boundary with @PublicApi and @ExperimentalApi annotations.
  • Gradle plugin support for Android application and library modules, including automatic KSP, runtime dependency, and processor option wiring.
  • Layout discovery through @FastLayoutConfig, @FastLayouts, and @FastLayoutPattern.
  • Per-layout JSON reports plus project-level layoutX2CReport HTML / JSON summaries for fallback visibility in local builds and CI.
  • Conservative fallback for unsupported nodes, unsupported attributes, <include>, ViewStub, and DataBinding semantics.
  • Incremental generation cache keyed by layout and resource dependency digests, including recursively included layouts and referenced values resources.
  • Static generation support for common Android / AndroidX views, safe ConstraintLayout subsets, styles, resource references, whitelisted custom views, and whitelisted BindingAdapter calls.

Changes since 0.4.1

  • Added a stable public runtime API surface for the 1.0 compatibility contract.
  • Expanded generation coverage for Text / View presentation attributes, common widgets, containers, app bars, ScrollView / ImageView combinations, and ConstraintLayout params including Guideline and common chain semantics.
  • Added safe custom view generation through @FastCustomViews, including custom views that inherit from supported platform containers.
  • Added whitelisted DataBinding BindingAdapter generation and native-style binding facade support for includes, nested includes, generated fields, root fields, variables, pending-binding state, and selected two-way bindings.
  • Improved fallback performance by batching sibling / subtree fallback inflation and caching missing generated registry lookups.
  • Improved codegen performance by reusing generated factory references and reducing repeated layout params configuration.
  • Improved resource resolution for AGP resource symbol files, external R jars, and precise resource dependency hashing.
  • Added Android equivalence coverage for generated inflate behavior, ViewStub, DataBinding, explicit View properties, compatibility widgets, and demo gallery flows.
  • Hardened release publishing with Maven Central GPG command signing and a Central Portal bundle path.

Compatibility

  • Minimum SDK: 23
  • Compile SDK: 36
  • Target SDK: 36
  • Android Gradle Plugin: 9.2.1
  • Kotlin: 2.2.21
  • KSP: 2.3.8
  • Java source / target compatibility: 11
  • Release build toolchain: JDK 21

Setup

plugins {
    id("io.github.donglua.layoutx2c") version "1.0.0"
}

Manual dependency setup:

dependencies {
    implementation("io.github.donglua.layoutx2c:runtime:1.0.0")
    ksp("io.github.donglua.layoutx2c:ksp-processor:1.0.0")
}

Published coordinates:

  • io.github.donglua.layoutx2c:runtime:1.0.0
  • io.github.donglua.layoutx2c:compiler-core:1.0.0
  • io.github.donglua.layoutx2c:ksp-processor:1.0.0
  • io.github.donglua.layoutx2c:gradle-plugin:1.0.0
  • Gradle plugin id: io.github.donglua.layoutx2c

Known boundaries

  • Unsupported View classes or unsafe attributes still fall back to platform inflation.
  • RecyclerView and ViewPager2 are generated as containers only. Adapter and runtime behavior remain application-owned.
  • DataBinding support is intentionally scoped. LayoutX2C does not replace the full native DataBinding runtime, expression engine, observable subscription model, or lifecycle dispatch.
  • Custom views and BindingAdapters only enter generated code when explicitly whitelisted.

0.4.1

02 Jun 12:08

Choose a tag to compare

更新内容

  • 修复 Binding facade 字段类型收集逻辑,保留 XML 中具体 View 类型,避免生成 binding 字段退化成过宽类型。
  • 修复 LayoutX2C 升级后仍可能复用旧 KSP digest cache 的问题。
  • digest 兼容键现在包含处理器 Implementation-Version,XML 未变但处理器版本变化时会自动重新生成产物,避免旧 fallback 输出被恢复。
  • Gradle 插件内置 runtime / ksp-processor 依赖版本同步升级到 0.4.1。

Commits

  • 8f7971c fix(binding): preserve concrete view field types
  • e68ca5c fix(ksp): invalidate stale generated cache on upgrades

验证

  • ./gradlew test :demo:assembleDebug :runtime:assembleRelease :demo:assembleRelease :demo:assembleDebugAndroidTest
  • GitHub Release workflow 通过,Maven artifacts 已发布。

LayoutX2C 0.4.0

02 Jun 10:01

Choose a tag to compare

主要更新

  • 为支持的 DataBinding 布局生成继承 ViewDataBinding{Name}X2CBinding facade。
  • fallback 子节点 inflate 改为走平台 XML parser 路径,提升 fallback 语义一致性。
  • DataBinding + ConstraintLayout root 在符合安全子集时保持生成路径。
  • 版本命名统一使用裸版本 tag:0.4.0

验证

  • ./gradlew test :demo:assembleDebug :runtime:assembleRelease :demo:assembleRelease :demo:assembleDebugAndroidTest --no-daemon --console=plain
  • ./gradlew :demo:kspDebugKotlin :demo:compileDebugKotlin --rerun-tasks --no-daemon --console=plain
  • ./gradlew :compiler-core:publishToMavenLocal :ksp-processor:publishToMavenLocal :gradle-plugin:publishToMavenLocal :runtime:publishReleasePublicationToMavenLocal --no-daemon --console=plain
  • GitHub Actions Release workflow 已在 0.4.0 tag 上成功完成。

说明

  • 复杂 DataBinding 表达式、BindingAdapter、Observable / LiveData 订阅和 lifecycle observer 语义仍交给原生 DataBinding runtime。
  • 不支持或无法安全等价生成的布局语义仍会 fallback 到平台 LayoutInflater

0.3.5

02 Jun 07:39

Choose a tag to compare

修复

  • 裸 KSP 接入时,优先从配置类中的 R import / 全限定 R.layout.* 推导生成代码使用的 R 包,避免源码 package 与 Android namespace 不一致时生成错误 R 引用。
  • 找不到源码 R 引用时,兜底从 Android Gradle namespace 推导 R 包。

0.3.4

02 Jun 06:55

Choose a tag to compare

修复

  • 修复 fallback 子节点的 dp LayoutParams 生成代码漏声明 density,避免 KSP 生成 Kotlin 编译时报 Unresolved reference 'density'。

发布

  • 版本号更新到 0.3.4。
  • 发布流水线在未配置 Gradle Plugin Portal 密钥时跳过 plugin portal 发布,避免影响 Maven artifacts 发布。