Why gradle cannot resolve version conflicts for local files?

In my app, I am having a library that uses another library which uses google.gson 2.8.8. I also have Android product flavor that uses google.gson 2.8.2 from a local file - "implementation fileTree(include: ["gson-${gsonVersion}.jar"], dir: gsonDir)" . Whenever I try to build my app for that flavor, gradle complains that it has a version conflict, but whenever I change the local file dependency to remote (implementation 'com.google.code.gson:gson:2.8.2') gradle would happily resolve the version conflict.

So I guess my question is, how are local file dependencies different from remote file dependencies that make gradle’s versioning resolution fail for local and not for remote?