更新至Android Studio 3.2后,Gradle Sync失败,没有特定错误-Android Gradle插件3.2.0

时间:2018-09-28 08:34:38

标签: android android-studio gradle

我最近更新了IDE,并且,如果我按照建议将Gradle插件更新到版本3.2.0,则无法同步我的项目。 Android Studio上的事件日志仅报告Gradle sync failed。 我尝试过:

  • cleanBuildCache
  • 重新启动
  • 使IDE缓存无效
  • 再做一遍,以防万一

这是IDEA日志:

2018-09-28 10:19:36,543 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SYNC_TASK_CREATED 
2018-09-28 10:19:36,545 [e-1136-b06]   INFO - e.project.sync.GradleSyncState - Started sync with Gradle for project '***'. 
2018-09-28 10:19:36,548 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SYNC_STARTED 
2018-09-28 10:19:36,548 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Starting batch update for project: Project '/Users/***/Documents/***/android/lib' com.***.***.lib 
2018-09-28 10:19:36,557 [thread 314]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home 
2018-09-28 10:19:36,558 [thread 314]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home 
2018-09-28 10:19:36,565 [thread 314]   INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: -Didea.version=3.2 -Djava.awt.headless=true -Pandroid.injected.build.model.only=true -Pandroid.injected.build.model.only.advanced=true -Pandroid.injected.invoked.from.ide=true -Pandroid.injected.build.model.only.versioned=3 -Pandroid.injected.studio.version=3.2.0.26 -Pandroid.builder.sdkDownload=false --init-script /private/var/folders/n8/8s0k679x36xdch74kff4y_r8n13428/T/ijinit.gradle 
2018-09-28 10:19:37,538 [thread 314]   INFO - e.project.sync.GradleSyncState - Started setup of project 'com.***.***.lib'. 
2018-09-28 10:19:37,540 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SETUP_STARTED 
2018-09-28 10:19:38,157 [e-1136-b06]   INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 28 Platform' (/Users/***/Library/Android/sdk) to module 'datalink' 
2018-09-28 10:19:38,187 [e-1136-b06]   INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 28 Platform' (/Users/***/Library/Android/sdk) to module 'connection' 
2018-09-28 10:19:38,190 [e-1136-b06]   INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 28 Platform' (/Users/***/Library/Android/sdk) to module 'transport' 
2018-09-28 10:19:38,209 [e-1136-b06]   INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 28 Platform' (/Users/***/Library/Android/sdk) to module 'vehicle' 
2018-09-28 10:19:38,381 [thread 314]   INFO - e.project.sync.GradleSyncState - Gradle sync failed (1 s 836 ms) 
2018-09-28 10:19:38,389 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender deactivation event: SYNC_FINISHED 
2018-09-28 10:19:38,389 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Finishing batch update for project: Project '/Users/***/Documents/***/android/lib' com.***.***.lib 
2018-09-28 10:19:38,427 [e-1136-b06]   INFO - pl.ProjectRootManagerComponent - project roots have changed 
2018-09-28 10:19:38,565 [thread 171]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 25ms; general responsiveness: ok; EDT responsiveness: ok 
2018-09-28 10:19:38,592 [thread 171]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 27ms; general responsiveness: ok; EDT responsiveness: ok 
2018-09-28 10:19:38,775 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Clearing symbols finished in 0.005 s. 
2018-09-28 10:19:38,776 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Building symbols in FAST mode, 0 source files from total 0 project files 
2018-09-28 10:19:38,777 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Loading symbols finished in 0.002 s. 
2018-09-28 10:19:38,777 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Loading Header Maps finished in 0.000 s. 
2018-09-28 10:19:38,777 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Loading Module Maps finished in 0.000 s. 
2018-09-28 10:19:38,778 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Saving Module Maps finished in 0.001 s. 
2018-09-28 10:19:38,778 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Loaded 0 tables for 0 files (0 project files) 
2018-09-28 10:19:38,778 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Building symbols for 0 source files 
2018-09-28 10:19:38,778 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Building symbols for 0 unused headers 
2018-09-28 10:19:38,778 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Building symbols finished in 0.000 s. 
2018-09-28 10:19:38,778 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Saving modified symbols for 0 files (0 tables of total 0) 
2018-09-28 10:19:38,779 [thread 171]   INFO -       #com.jetbrains.cidr.lang - Saving symbols finished in 0.000 s. 

运行./gradlew build成功构建,但是Studio仍然抱怨Gradle project sync failed,我无法运行。

Android Studio 3.2 / Android Gradle插件3.2.0 / 摇篮包装器4.10.2 / MacOS High Sierra 10.13.4

谢谢您的任何帮助。

1 个答案:

答案 0 :(得分:1)

全新的gradle,gradle android插件和Android Studio 3.2出现了相同的问题

我已经创建了一个单独的测试项目,并开始逐个移动我当前的项目模块,以识别同步问题。

在我的情况下,问题是由库清单文件中的minSdkVersion不匹配引起的。

在我的项目中,我有很多android库,它们的清单文件中都设置了minSdkVersion。在以前的gradle插件/ Android Studio版本中,同步过程忽略了这些清单值,而使用build.gradle文件中定义的值。在新版本的gradle插件中,这似乎是个问题。

我做了什么:从库/应用程序清单中删除了所有minSdkVersion / targetSdkVersion xml条目。现在我的项目可以正确同步了。

希望能提供帮助。