How to import dependencies after declaring them in the build.gradle file?

I'm just starting to work on an android studio and starting to explore the world of Gradle. So I created a project in Android Studio, opened build.gradle and added the dependencies as shown below:

 dependencies { compile 'com.android.support:support-v4:19.0.1' compile 'com.android.support:appcompat-v7:19.0.1' compile 'com.squareup.retrofit:retrofit:1.3.0' compile 'com.jakewharton.timber:timber:2.1.0' } 

After that, I noticed a tooltip that appeared on build.gradle that says:

You can configure the Gradle shell to use the distribution with sources. It will provide the IDE Gradle API / DSL documentation "

I ignore this, and I find neither wood nor modifications in external libraries after I try to build the project. Obviously, I missed something. I thought that after declaring dependencies and creating a click, specific libraries would be imported automatically, but yes, I was wrong.

So, I agree and apply the hint that appeared on build.gradle , and then the project was updated, after which all the dependencies were available in the "External Libraries".

So the question is:

  • How to ensure that all dependencies are present after the declaration in build.gradle ?

I read that I can do this using the GUI by clicking on the import modules, but I want to find out if there are other ways.

+6
source share
2 answers

If you are not using Android Studio 0.4.3, please update it - in this version there are fixes that do not allow new applications to be fully visible for your project in the IDE (although in fact it will be well built). If you are not using 0.4.3 yet, this will probably fix your problem.

As for the message about setting up the Gradle wrapper to use sources, this refers to the fact that the wrapper loads the version of Gradle itself, which includes the source code in Gradle. This allows the IDE to smarter syntax when editing build.gradle files from the IDE. What he does is change this URL in the gradle / wrapper / gradle -wrapper.properties file:

 distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip 

:

 distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip 
+3
source

Yo can check your dependencies from the Android Studio GUI by following these steps:

  • Go to File > Project Structure or right-click on the project and select Open Module Settings
  • An open window will contain all of your modules listed in the left pane and some tabs in the right pane.
  • Select the module for which you want to check the dependencies and select the "Dependencies" tab in the right pane.

You will see all the dependencies that you defined in your build.gradle file, also using the β€œ+” icon, available in the right pane, which you can add more.

Dependencies GUI

+1
source

All Articles