N Kaushik

Fix- Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

November 29, 2021

How to fix Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly:

This is a common issue in Android Studio. If your Gradle sync failed, you might get an error with a message that describes your issue. This error is easy to fix if the reason is mentioned.

But, if you are getting the following error without any specific reason, it becomes harder to solve.

Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

Android gradle sync failed

It shows three buttons Try Again, Open Build View and Show log in Explorer.

  • If you click on the Try Again button, it will try to sync the project again and it will fail.
  • If you click on the Open Build View button, it will open the Build view in Android studio as like below:

Android Studio build view

If you see any error logs, you can fix it. But in my case, there is no error logs except the time-stamps.

The third button can help you in some cases. Don’t use Android Studio after the sync failed and click on that button, Show Log in Explorer.

It will open a folder containing idea.log file. Android studio or IntelliJ Idea logs its exceptions and other log messages in this file. You can move to the bottom of the file to get the error. You will get the exception stack-trace with details.

In my case it was:

2021-11-29 18:47:22,583 [  73313]   WARN - ea.gradle.project.sync.SdkSync - Module: 'app' platform 'android-30' not found. 
2021-11-29 18:47:22,585 [  73315]  ERROR - intellij.openapi.progress.Task - Module: 'app' platform 'android-30' not found. 
com.android.tools.idea.gradle.project.sync.idea.issues.SdkPlatformNotFoundException: Module: 'app' platform 'android-30' not found.
	at com.android.tools.idea.gradle.project.sync.idea.SdkSyncUtil.computeSdkReloadingAsNeeded(SdkSyncUtil.kt:129)
	at com.android.tools.idea.projectsystem.gradle.sync.AndroidModuleDataService.postProcess(AndroidModuleDataService.kt:216)
	at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.lambda$doImportData$1(ProjectDataManagerImpl.java:276)
	at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:126)
	at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:206)
	at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:213)
	at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populateProject(IdeaSyncPopulateProjectTask.java:53)
	at com.android.tools.idea.gradle.project.sync.idea.ProjectSetUpTask.doPopulateProject(ProjectSetUpTask.java:54)
	at com.android.tools.idea.gradle.project.sync.idea.ProjectSetUpTask.onSuccess(ProjectSetUpTask.java:48)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.handExecutionResult(ExternalSystemUtil.java:584)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.executeImpl(ExternalSystemUtil.java:564)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.lambda$execute$1(ExternalSystemUtil.java:389)
	at com.intellij.openapi.project.DumbServiceHeavyActivities.suspendIndexingAndRun(DumbServiceHeavyActivities.java:21)
	at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:185)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:389)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4.run(ExternalSystemUtil.java:666)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:962)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:472)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:834)
2021-11-29 18:47:22,586 [  73316]  ERROR - intellij.openapi.progress.Task - Android Studio Arctic Fox | 2020.3.1 Patch 3  Build #AI-203.7717.56.2031.7784292 
2021-11-29 18:47:22,586 [  73316]  ERROR - intellij.openapi.progress.Task - JDK: 11.0.10; VM: OpenJDK 64-Bit Server VM; Vendor: Oracle Corporation 
2021-11-29 18:47:22,586 [  73316]  ERROR - intellij.openapi.progress.Task - OS: Windows 10 
2021-11-29 18:47:22,586 [  73316]  ERROR - intellij.openapi.progress.Task - Last Action: Android.SyncProject 
2021-11-29 18:47:22,697 [  73427]   INFO - cState$SyncStateUpdaterService - stopTrackingTask(RESOLVE_PROJECT:3) 
2021-11-29 18:47:22,697 [  73427]   WARN - e.project.sync.GradleSyncState - Gradle sync failed: Sync failed: reason unknown (1 s 960 ms) 
2021-11-29 18:47:27,844 [  78574]   INFO - j.ide.actions.RevealFileAction - Exit code 1 

You can see that it clearly says SDK-30 is not found.

I had to go to app/build.gradle and update it with the SDK that is currently installed in my system. It was fixed.


Subscribe to my Newsletter