I am just starting to work on android studio and beginning to explore the world of Gradle. So I created a project in Android Studio, opened up build.gradle
and added dependencies like the 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 this I notice a tip popping up on build.gradle
which says:
You can configure Gradle wrapper to use distribution with sources. It will provide IDE with Gradle API/DSL documentation"
I ignore this and I don't find either timber or retrofit in the external libraries after I try building the project. Obviously I was missing something. I believed that after declaring the dependencies and clicking build, the particular libraries will be auto imported but yes, I was wrong.
So I agree and apply the tip which popped up on build.gradle
and then the project got refreshed, post which all the dependencies were available in the "External Libraries".
So the question is:
build.gradle
? I have read that I can do this the GUI way by clicking on import modules but I want to find out if there are other ways
If you're not using Android Studio 0.4.3, please upgrade to it -- there are bugfixes in that version that prevent newly-added dependencies from being completely visible to your project in the IDE (though it would actually build okay). If you're not already running 0.4.3, that will probably fix your problem.
As for the message about configuring the Gradle wrapper to use sources, that applies to having the wrapper download a version of Gradle itself that includes the source code to Gradle. Doing this allows the IDE to be smarter about syntax highlighting when you're editing build.gradle files from the IDE. What that tip does is it changes this URL in your gradle/wrapper/gradle-wrapper.properties file from this:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
to this:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
Yo can check your dependencies from Android Studio GUI using following steps :
File > Project Structure
or Right click on project and
choose Open Module Settings
"Dependencies"
tab from Right pane.You will see all dependencies there which you have defined in your build.gradle
file, also using "+" icon available on right pane you can add more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With