Home Difference between three dependencies
Reply: 2

Difference between three dependencies

Aada
1#
Aada Published in 2018-02-14 09:03:55Z

in one example, I saw three dependencies block in build.gradle. example: root folder: build.gradle 1.

buildscript{
 dependencies{
 }
}

2.Under android block

android{
 dependencies{
 }
}
  1. I see one more dependencies block on root folder

    buildscript{ } dependencies{ } android{ }

First two are been explained in Android developer site. 1st: is applicable for complete project 2nd: per module.

I am not understanding what 3rd dependency block means.

Nikhil PV
2#
Nikhil PV Reply to 2018-02-14 09:43:55Z

It's a bit confusing because Android Studio by default shows both build.gradle files right next to each other (when using the Android view).

If you switch to the Project view you can see the actual structure and where the different build.gradle files are located.

The build.gradle (Project: MyApplication) file is in the root folder of the project and its configuration settings apply to every module in the project. A module is an isolated piece of the bigger project. In a multi-module project, these modules have their own jobs but work together to form the whole project. Most Android projects only have one module, the app module.

The build.gradle (Module: app) file here is in the app folder. Its build settings apply only to the app module. If there were another module, then the it would have its own build.gradle file, too. As an example, I made a library project with three modules: a library module, a demo app module, and another app module that I plan to use for testing. Each of them have their own build.gradle files that I can tweak.

In a basic project, almost everything you need to edit will be in the app module's build.gradle file. You can remember it like this:

You're making an app, so go to the build.gradle (Module: app) file.

Further reading

  • Configure Your Build (Android documentation--very readable and useful)
  • Introduction to multi-project builds (Gradle documentation)
Gabriele Mariotti
3#
Gabriele Mariotti Reply to 2018-02-15 08:13:45Z

First two are been explained in Android developer site. 1st: is applicable for complete project 2nd: per module.

It is not exact.

The buildscript block can be specified in the root level but also in the module build.gradle file.
These dependencies block only controls the dependencies for the buildscript process itself, not for the application code.

2.Under android block

android{
 dependencies{
 }
}

It is not correct.
The correct syntax is:

android {
  ...
}
...
dependencies {
    ...
}

Don't put these dependencies in the top-level file.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302049 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO