Getting Gradle dependencies in IntelliJ IDEA using Gradle build

前端 未结 7 1171
一个人的身影
一个人的身影 2021-01-29 20:46

Grade build, even from inside IntelliJ IDEA does not put the dependencies into the \"External Libraries\" folder, so these classes don\'t show up as suggestions in the editor an

相关标签:
7条回答
  • 2021-01-29 21:24

    When importing an existing Gradle project (one with a build.gradle) into IntelliJ IDEA, when presented with the following screen, select Import from external model -> Gradle.

    Optionally, select Auto Import on the next screen to automatically import new dependencies.

    0 讨论(0)
  • In my case,I was getting error while refreshing gradle ('View'->Tool Windows->Gradle) tab and hit "refresh" and getting this error no such property gradleversion for class jetgradleplugin.

    Had to install latest intellij compatible with gradle 5+

    0 讨论(0)
  • 2021-01-29 21:32

    You either need to import the project as a Gradle project from within Idea. When you add a dependency you need to open the Gradle window and perform a refresh.

    Alternatively generate the project files from gradle with this:

    build.gradle:

    apply plugin: 'idea'
    

    And then run:

    $ gradle idea
    

    If you modify the dependencies you will need to rerun the above again.

    0 讨论(0)
  • 2021-01-29 21:35

    For those who are getting the "Unable to resolve dependencies" error:
    Toggle "Offline Mode" off
    ('View'->Tool Windows->Gradle)

    gradle window

    0 讨论(0)
  • 2021-01-29 21:35

    Tried everything in this thread and nothing worked for me in IntelliJ 2020.2. This answer did the trick, but I had to set the correct path to the JDK and choose it in Gradle settings after that (as showed in figures bellow):

    1. Setting the correct path for the Java SDK (under File->Project Structure):

    1. In Gradle Window, click in "Gradle Settings..."

    1. Select the correct SDK from (1) here:

    After that, the option "Reload All Gradle Projects" downloaded all dependencies as expected.

    Cheers.

    0 讨论(0)
  • 2021-01-29 21:41

    After adding dependencies open "Gradle" ('View'->Tool Windows->Gradle) tab and hit "refresh"

    example of adding (compile 'io.reactivex:rxjava:1.1.0'):

    If Idea still can not resolve dependency, hence it is possibly the dependency is not in mavenCentral() repository and you need add repository where this dependency located into repositories{}

    0 讨论(0)
提交回复
热议问题