Skip to content
 
 

Repository files navigation

viewbinding-migration-plugin

A Plugin for Android Studio to help with migrating from synthetic properties to ViewBinding.

Installation

  • Download *.jar from latest release.
  • In Android Studio: Preferences > Plugins > Install Plugin from Disk.

Usage

  • Invoke the Rename Variables for ViewBinding action inside of any Kotlin file.
  • The kotlin synthetic import statements should still be present before using.
  • Usage inside files that are already using ViewBinding is possible, but pointless.

Screenshot 2022-11-25 at 11 38 55 copy

Screenshot 2022-11-25 at 10 39 23

Known Issues

  • Current build is compatible with Android Studio Iguana only, and not above.
  • Does not match properties referenced as this.propertyName or view.propertyName.
  • Does not match properties in switch expression result clauses, i.e.
        private fun getTextField(field: FormFieldEnum): TextInputLayout {
          return when (field) {
              FormFieldEnum.FIRST_NAME -> firstName /* not matched */
  • After a successful rename, the IDE will be left with "Val cannot be reassigned" errors.
    • This looks like an IntelliJ issue - it persists even after reloading.
  • I have examples where it has lost the first fragment of a snake-case name :-/

Notes

  • Synthetic properties work when called on a super-view. These must be manually wired up to the correct child view binding (once it's been identified).
  • This includes included views that don't have an ID. View binding will not generate properties for these until you add an ID.

About

A Plugin for Android Studio to help with migrating from synthetic properties to ViewBinding.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages