简体   繁体   English

在IntelliJ Idea中输入build.gradle很慢

[英]Typing in build.gradle in IntelliJ Idea is slow

So, I got weird problem. 所以,我遇到了奇怪的问题。 I moved from Eclipse to IntelliJ Idea. 我从Eclipse迁移到IntelliJ Idea。 And when I'm typing/editing file build.gradle it's... lagging, very hard to write anything there. 当我在输入/编辑文件build.gradle时,它是......滞后,很难在那里写任何东西。 What can cause that? 是什么导致的? Refreshing didn't help. 刷新没有帮助。

Added plugin: apply plugin: 'idea' But can't see in IntelliJ Idea tasks for idea in Gradle perspective. 添加了插件:apply plugin:'idea'但是在Gradle透视图中无法在IntelliJ Idea任务中看到想法。 When I open Eclipse everythings works fine, with Gradle plugin for eclipse I can see these tasks in the project etc. the idea tasks are only available from command line, not from intellij idea gui. 当我打开Eclipse时,每个人都可以正常工作,使用Gradle插件进行eclipse我可以在项目中看到这些任务等。想法任务只能从命令行获得,而不是来自intellij idea gui。

But I want to fix that annoying thing with typing in build.gradle... why it is lagging?! 但是我想在build.gradle中输入那个烦人的东西...为什么它会滞后?!

Please, help. 请帮忙。

Been troubled by this myself recently. 最近我自己也很困扰。 Was extremely slow just editing text in the build file like OP describes. 像OP描述的那样只是编辑构建文件中的文本非常慢。 Just solved it. 刚解决了。 When you've opened a project and added a build.gradle file afterwards it seems you have to "link the gradle project" for intellij to work as it should while editing this file. 当您打开一个项目并在之后添加了build.gradle文件时,似乎您必须“链接gradle项目”以便intellij在编辑此文件时正常工作。

One way of doing it: 一种方法:

  • Close Intellij if it's open. 关闭Intellij如果它打开了。
  • When the IDE is loaded up it'll give you a notification of an unlinked gradle project. 当IDE加载时,它会给你一个未链接的gradle项目的通知。 Follow the tip in that notification box and all should be well. 按照该通知框中的提示,一切都应该很好。

A second way: 第二种方式:

  • Close the project from intellij. 从intellij关闭项目。 File -> close project. 文件 - >关闭项目。
  • In the following welcome dialogue choose to import a project. 在以下欢迎对话框中选择导入项目。
  • Pick "import from an external model" and then select Gradle as the model. 选择“从外部模型导入”,然后选择Gradle作为模型。 Should be working. 应该工作。

The following exclusion to my save actions plugin alleviated the problem for me: build\\.gradle 以下对我的保存操作插件的排除缓解了我的问题: build\\.gradle

在此输入图像描述

I have worked on android, that uses gradle for building. 我曾在android上工作过,它使用gradle进行构建。 So assuming, that the same works for you, here are a few things that you should make sure of - 所以假设,同样适合你,这里有一些你应该确定的事情 -

  1. Have the latest version of Gradle. 拥有最新版本的Gradle。 v2.4 for eg has a huge performance boost over previous versions. 例如,v2.4与以前的版本相比具有巨大的性能提升。 see this http://gradle.org/docs/current/userguide/gradle_wrapper.html to help yourself with that. 请参阅此http://gradle.org/docs/current/userguide/gradle_wrapper.html以帮助自己。

  2. The next step is to enable the Gradle daemon. 下一步是启用Gradle守护程序。 Using Daemon makes your builds startup faster. 使用守护程序可以使您的构建启动更快。

  3. Moving on, enable parallel build for your project. 继续,为您的项目启用并行构建。 Parallel builds will cause your projects with multiple modules to be built in parallel. 并行构建将导致具有多个模块的项目并行构建。 You should usually be able to do this by adding a file named *gradle.properties* in your .gradle in your home directory (ie, ~/.gradle/gradle.properties ). 您通常可以通过在主目录中的.gradle中添加名为*gradle.properties*的文件(即~/.gradle/gradle.properties )来完成此操作。 Add org.gradle.daemon=true org.gradle.parallel=true to the file. org.gradle.daemon=true org.gradle.parallel=true添加到文件中。 If this doesnt work, find a way to enable the same on your computer. 如果这不起作用,请找到在计算机上启用相同功能的方法。 It helps. 它有助于。

These work pretty well with regard to gradle speed when used while developing android apps using android studio. 这些在使用android studio开发Android应用程序时使用时的gradle速度相当不错。 I would help you out with how to enable daemon as well but I am not aware of that. 我会帮助你了解如何启用守护进程,但我不知道这一点。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM