I go to build.gradle and click sync now. Then it worked.

Update :

File -> Sync Project with Gradle Files (Android Studio 3.1.1)

Tools -> Android -> Sync Project with Gradle Files (Android Studio 3.0.1)

Or You can click on the icon from the toolbar.

Sync Project Icon

This answer may not help works for later version as Android studio Team work on making the tool more better, the way to sync may be different in the next version of Android Studio.

COMMON WAY that may helps is try to sync project and then Invalidate Caches and Restart Android Studio.

Solution for Android Studio 3.1.2 [See below answer]

See Latest Android Studio version