This details how to handle build dependencies in Android Studio 1.0.2. I'll use an example to illustrate. We'll add a dependency to Apache's
- Go to
File -> Project Structureto open the
- Click the
- Click the add button (the
Library dependencyto open the
Choose Library Dependencydialog.
org.apache.httpcomponents:httpmimeand click the search icon.
- Choose one of the results and click the
Project Structuredialog as well.
Now open your module's
build.gradle file (not the project's gradle file) under the
Gradle Scripts and note that
compile 'org.apache.httpcomponents:httpmime:4.4-beta1' has been added in the
dependencies section. All that the previous procedure did is add some config to your build file. Building your project reads this file and does the necessary compilation based on your config.
To show that this library dependency is encapsulated by the entry in the
build.gradle file, reopen the
Project Structure -> Dependencies tab and note your library is listed. Close the dialog and delete the above line from your
build.gradle file. Now reopen the dialog and note that the library is gone.
File dependency (importing jars)
- Download the jar you need.
- Add it to your module's
libsfolder. Directly in the file system go to your project folder, and then your module folder (probably
mobile), and then
- Build your project.
Note that in your module's
build.gradle file, in the
dependencies section, this line is including those jars you added to your build:
compile fileTree(dir: 'libs', include: ['*.jar'])