Getting Gradle dependencies in IntelliJ IDEA using Gradle build
For those who are getting the "Unable to resolve dependencies" error:
Toggle "Offline Mode" off
('View'->Tool Windows->Gradle)
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.
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{}
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.