I updated to gradle 4.0.1 and started receiving following error
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
My project doesn't use that dependency so I searched globally for it, and it it only comes up inside
build/intermediates/lint-cache/maven.google/com/google/android/gms/group-index.xml
as this line
<play-services-measurement-base versions="15.0.0,15.0.2"/>
So I tried deleting my build folder and cleaning the project, but it regenerates it with same values :/ hence error still remains
The actual problem is discussed in the May, 23rd release note of https://developers.google.com/android/guides/releases#may_23_2018
Basically, you need to bump all Play Services and Firebase libraries to their latest version (which may be different for each since version 15). You may use https://mvnrepository.com/ to find the latest version for each library.
See also: https://firebase.google.com/support/release-notes/android#20180523