I go to
build.gradle and click sync now. Then it worked.
Sync Project with Gradle Files (Android Studio 3.1.1)
Sync Project with Gradle Files (Android Studio 3.0.1)
Or You can click on the icon from the toolbar.
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.
How to “select Android SDK” in Android Studio?
FIX FOR 3.1.2 OR NEWER VERSIONS
Some of my colleagues and I have faced the same issue on AS 3.1.2, but a simple Sync didn’t help us. For us, the solution was a bit different:
- File -> Invalidate Caches -> Invalidate
- File -> Close Project.
- Remove the project from the AS project selector window.
- Quit from Android Studio
- Start AS and open project again
EXTRA ADVICE IF YOU ARE FACING THIS ISSUE CONSTANTLY
Some of you are constantly facing this issue, and this “solution” fixes it only temporarily. At the time we started getting this error, we used gradle wrapper 4.6 and Android gradle plugin 3.1.0, but since then we went back to gradle 4.4 and we use it with the latest Android gradle plugin, and we haven’t seen this issue since then.
In Android Studio 3 and above, for Windows, Mac and Linux:
File -> Sync Project with Gradle Files
Or you can do this by shortcut key:
Press ⌘ + Shift + A (Mac) or Ctrl + Shift + A (Windows, Linux). Then pop-up a Edit-Text and write
"Sync Project with Gradle Files". Then press double click on the option.
Your problem is solved! It’ll sync your gradle file with your project file.
or edit any of your module
gradle and then sync.
How to “select Android SDK” in Android Studio? Answer #5:
"Ctrl+shift+A" and in the pop-up
"Sync Project with Gradle Files". After that double click on the appeared option. It will then sync your
SDK with the project file.
Just go to the (app level)
build.gradle file, give an empty space somewhere and click on sync, once gradle shows sync complete then the Error will be gone.
This is the easiest way to fix this issue:
- Add a comment line to the gradle file
- It will then ask you to Sync.
- Click ‘Sync Now‘
Viola! You’re done.
The menu structure and options have changed slightly as of Android 3.2.0. I fixed this error by changing the Module SDK in the following menu:
File > Project Structure > Modules > App File > Dependencies Tab > Module SDK
Make sure to hit Apply to save your changes.
Hope you learned something from this post. The primary source of this article is StackOverflow.
Follow Programming Articles for more!