Android Databinding – Variable is already defined

Recently I added a listener variable in the layout XML of one of my files. It looked like this:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="">

            type="" />


And I got the following exception from the DataBinding Variable paymentActionListe already defined. Then I found THIS issue. It was mentioned in it that the binding variables have a limit of 20 characters. I opened another generated DataBinding file and saw that there were 2 variables connected with each other: boolean paymentListObj and Listener paymentList. These same variables in the generated file of my XML had the exact same name so the truncation of them was not right.

The solution was to rename the variable paymentActionListener to listener and everything was fine. Shorter variable names prevent the DataBinding library from generating wrong variable names. I hope this bug will be fixed soon.

You may also like...