ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1

Disclaimer:

The fix below is intended to solve a specific problem with some
dependencies conflict, mostly databinding issues can cause this error but are
only a consequence of wrong XML or code and the
solution below will not work in this case. Double check your XML/code correctness before trying the below solution.

This is a known problem with some databinding versions (which is embedded in Android Studio) and other dependencies like Room which import different versions of org.antlr:antlr4 library.

UPDATE: 12/06/2020 (dd/MM/yyyy)

If you use Room, updating to Room 2.3.0-alpha01 or above should remove the error because they have fixed the problem here: https://issuetracker.google.com/issues/150106190


Put this configuration in the app build.gradle

//groovy
configurations.all {
    resolutionStrategy.force "org.antlr:antlr4-runtime:4.7.1"
    resolutionStrategy.force "org.antlr:antlr4-tool:4.7.1"
}

//kotlin DSL
configurations.all {
    resolutionStrategy {
        force("org.antlr:antlr4-runtime:4.7.1")
        force("org.antlr:antlr4-tool:4.7.1")
    }
}

If you still have problems, you can try using the 4.5.3 version above
instead of 4.7.1 to downgrade the library

Reference

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)