I know this is probably a dead thread but just in case someone stumbles upon here having an identical problem – your manifest might be missing the following meta information:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Declare it within the <application>
element and your code should work. I ran into the same issue following a youtube tutorial that skipped this step and only when carefully going through the original Google tutorial I noticed the missing code.
Anyway, hope this helps someone.