Gradle任务未显示在AndroidStudio4.2的gradle工具窗口中

我刚刚将 Android Studio 更新到了 4.2 版。我很惊讶在我的项目中没有看到 Gradle 任务。

在之前的版本 4.1.3 中,我可以看到如下所示的任务:

但是现在我只看到了 4.2 版本中的依赖项:

我尝试清除 Android Studio 的缓存并再次同步我的项目,但没有任何变化。

这是功能更改吗?

回答

好的,我找到了在 android studio 4.2 中出现这种行为的原因。

这是预期的行为。我在这篇文章中找到了答案:https : //issuetracker.google.com/issues/185420705。

Gradle 任务列表很大,而且在 Android 项目中填充速度很慢。出于性能原因,默认情况下禁用此功能。您可以在:设置 | 中重新启用它。实验 | 在 Gradle 同步期间不要构建 Gradle 任务列表。

通过单击“将项目与 gradle 文件同步”图标重新加载 Gradle 项目,任务将出现。

将此实验性更改放入 android studio 的发行说明中可能很酷4.2

  • Thank-you so much for this! I've been fighting this for the past few hours.

    Seems like a bit of a strange feature/option. I can see that it might be a performance problem, but how are you supposed to run a task if they aren't shown anywhere? (They aren't even displayed in from 'Run Anything')

    Totally agree this needs to be in the Release Notes.

  • Thanks for the solution, maybe they should ask or even add a UI button if this task is expensive and they don't want to execute it every time!!

回答

转到File -> Settings -> Experimental并取消选中Do not build Gradle task list during Gradle sync,然后同步项目File -> Sync Project with Gradle Files。如果问题仍然存在,只需重新启动 Android Studio。

1.

2.

  • Thanks, man you saved my day! I spent 5 hours looking for a solution to the problem in different places. But for now I want to find the coder (or manager) who created this weird checkbox and say all what I think about him.
  • Thanks a lot for this Alex ! It worked like a charm. I think this is a weird feature. Anyway, your workaround saved me from a lot of head-scratching lol
  • it works like charm . thnx
  • This one saved me, thanks!
  • Amazing! This just worked like a charm to me as well.

回答

解决方案1:

您也可以使用以下 gradle 命令来获取所有任务并在终端中运行它们

./gradlew tasks --all

解决方案 2。

您还可以创建运行配置来运行如下任务:

第1步:

第2步:

第 3 步:

然后您的运行配置将像步骤 1 图像中那样列出。您可以选择并像往常一样简单地运行它。


以上是Gradle任务未显示在AndroidStudio4.2的gradle工具窗口中的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>