A similar issue arose with me when I tried to add Firebase Database to my project.
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.3'
The issue can be resolved by downgrading or upgrading both the versions to a similar level. So I downgraded firebase database to
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
and it worked! All available versions can be searched on this site: https://mvnrepository.com/