Android Studio问题解决:Gradle sync failed: Sync failed: reason unknown

文章目录

  • 一、遇到问题
  • 二、排查问题
  • 三、解决问题

一、遇到问题

  • 今天遇到Gradle sync failed: Sync failed: reason unknown这个问题
  • 也不说清楚具体啥问题,摸不着头脑,搞了好久

Android Studio问题解决:Gradle sync failed: Sync failed: reason unknown_第1张图片

12:53	Gradle sync started

12:53	Gradle sync failed: Sync failed: reason unknown (2 s 672 ms)

12:53	Project QuestSpaAndroid is using the following JDK location when running Gradle:
			C:/Program Files/Java/jdk1.8.0_261
			Using different JDK locations on different processes might cause Gradle to
			spawn multiple daemons, for example, by executing Gradle tasks from a terminal
			while using Android Studio.
			More info...
			Select a JDK
			Do not show this warning again

二、排查问题

  • 最后在这个路径C:\Users\Administrator\AppData\Local\Google\AndroidStudio2021.1\log下面,找到这个idea.log
  • 才看到更为详细的日志信息

Android Studio问题解决:Gradle sync failed: Sync failed: reason unknown_第2张图片

2022-04-27 12:53:23,787 [  97624]   WARN - ea.gradle.project.sync.SdkSync - Module: 'picture_library' platform 'android-23' not found. 
2022-04-27 12:53:23,788 [  97625]  ERROR - intellij.openapi.progress.Task - Module: 'picture_library' platform 'android-23' not found. 
com.android.tools.idea.gradle.project.sync.idea.issues.SdkPlatformNotFoundException: Module: 'picture_library' platform 'android-23' 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:221)
	at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.lambda$doImportData$1(ProjectDataManagerImpl.java:278)
	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:208)
	at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:215)
	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:592)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.executeImpl(ExternalSystemUtil.java:572)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.lambda$execute$1(ExternalSystemUtil.java:397)
	at com.intellij.openapi.project.DumbServiceHeavyActivities.suspendIndexingAndRun(DumbServiceHeavyActivities.java:21)
	at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:189)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:397)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4.run(ExternalSystemUtil.java:674)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:998)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:497)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:228)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:228)
	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:829)
2022-04-27 12:53:23,789 [  97626]  ERROR - intellij.openapi.progress.Task - Android Studio Bumblebee | 2021.1.1 Patch 3  Build #AI-211.7628.21.2111.8309675 
2022-04-27 12:53:23,789 [  97626]  ERROR - intellij.openapi.progress.Task - JDK: 11.0.11; VM: OpenJDK 64-Bit Server VM; Vendor: Oracle Corporation 
2022-04-27 12:53:23,789 [  97626]  ERROR - intellij.openapi.progress.Task - OS: Windows 10 
2022-04-27 12:53:23,789 [  97626]  ERROR - intellij.openapi.progress.Task - Last Action: Android.SyncProject 
2022-04-27 12:53:23,889 [  97726]   INFO - cState$SyncStateUpdaterService - stopTrackingTask(RESOLVE_PROJECT:2) 
2022-04-27 12:53:23,889 [  97726]   WARN - e.project.sync.GradleSyncState - Gradle sync failed: Sync failed: reason unknown (2 s 672 ms) 

三、解决问题

  • 关键日志就在于Module: 'picture_library' platform 'android-23' not found.
  • 所以打开Tools——>SDK Manager

Android Studio问题解决:Gradle sync failed: Sync failed: reason unknown_第3张图片

Android Studio问题解决:Gradle sync failed: Sync failed: reason unknown_第4张图片

觉得好,就一键三连呗(点赞+收藏+关注)

你可能感兴趣的:(Android,Android,Android,Studio,Gradle,Sync,reason,unknown,idea)