Android databinding is defined multiple times

1. Error reporting:

        When AndroidStudio runs the code, the compiler reports  Type androidx.databinding.Bindable is defined multiple times...

2. Solution:

        Click Build -> Clean Project, close the compiler and then reopen it.

3. Solution process:

        When using Android Studio to switch code branches, resource conflicts may occasionally occur.

        Probably the following reasons

        1. The newly added code has not been committed, and switching between them can easily cause resource problems.

        2. Some resources (including aar, jar...) in different branches have different versions, or the newly introduced SDK contains these resources, which will also cause conflicts.

        3. The cache of Android Studio itself (I don’t know if this is a compiler bug), this is the case I encountered. And using invalidate caches to clear the cache is useless. Be sure to use Build -> Clean Project. After clearing it, completely close androidStudio and wait for a while to open it (compare the code when the error was reported, without any changes), and it will be fine. 

        My compiler version: [AndroidStudio2020.3.1, mac version]

Guess you like

Origin blog.csdn.net/qq_42111674/article/details/132278551