[android] Syncing Android Studio project with Gradle files

I was working on a project, and then I got a prompt to update Android Studio. After I did that, I started getting this error when trying to run my app Error

It says

The project may need to be synced with Gradle files

How do I solve this?

This question is related to android android-studio

The answer is


i had this problem yesterday. can you folow the local path in windows explorer?

(C:\users\..\AndroidStudioProjects\SharedPreferencesDemoProject\SharedPreferencesDemo\build\apk\) 

i had to manually create the 'apk' directory in '\build', then the problem was fixed


I've had this problem after installing the genymotion (another android amulator) plugin. A closer inspection reveled that gradle needs SDK tools version 19.1.0 in order to run (I had 19.0.3 previously).

To fix it, I had to edit build.gradle and under android I changed to: buildToolsVersion 19.1.0

Then I had to rebuild again, and the error was gone.


The gradle versions in android studio and your code is not the same. This is why even after you update the gradle version on android studio, the error still persist.

So, edit the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file:

distributionUrl = https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Ref: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle


I am using Android Studio 4 developing a Fluter/Dart application. There does not seem to be a Sync project with gradle button or file menu item, there is no clean or rebuild either.

I fixed the problem by removing the .idea folder. The suggestion included removing .gradle as well, but it did not exist.


Old Answer

When trying to run the application, instead of selecting the directory highlighted here in blueenter image description here

I selected the subdirectory instead

enter image description here

and clicked "run".All the issues with Gradle are automatically resolved and the missing apk directory is automatically created.

New Solution

The Sync project with gradle files button disappeared from Android Studio for a while.Its back and you can find it here:

enter image description here

hit the button and wait for the task to complete


Keys combination:

Ctrl + F5

Syncs the project with Gradle files.