Differences between two build.gradle configurations in Android project and app

Source: Internet
Author: User

Android Development also quite a long time, from the beginning of the use of the Androidstudio development, but said actually their own as (Androidstudio short) really is not understand not deep, well, in fact, I only know as is a very powerful tool, I have to learn a lot.
So, this is the time to learn the use of Rtrolambda and Butterknife, I found that their import was introduced in Project Build.gradle rather than in the app's Build.gradle, which made me feel a bit depressed, because I didn't know the difference between the two gradle, and here's a summary.

  Generally after creating an Android project, there are two gradle: a Build.gradle (APP), a Build.gradle (project), as the name implies is a configuration of the entire project is used to configure the app.

first, the difference of dependencies in Gradle:

The following English is an explanation of the difference between compile and classpath:

I ' m going to guess this you ' re referencing compile and classpath
Within the dependencies {} block. If that's so, those was dependency
Configurations.

A configuration is simply a named set of dependencies. The Compile
Configuration is created by the Java plugin. The Classpath
Configuration is commonly seen in the BUILDSRC {} block where one
Needs to declare dependencies for the Build.gradle, itself (for
Plugins, perhaps).

The role of Classpath:

Buildscript itself needs something to run, use Classpath

The role of Complie:

Your project needs something to run, use compile

The dependencies of Gradle in Project is that adding dependencies is using classpath, and classpath is generally adding something that the buildscript itself needs to run, So what is buildscript for? Buildscript is a resource that is used to load the Gradle script itself, including dependencies, third-party plug-ins, maven warehouse addresses, and so on.
In the Gradle in the app , add the dependent packages that the application needs to dependencies, which is what the project needs to run.

Two What kinds of compile are there?

Compile
Compile is for all build type and favlors to be compiled and packaged into the final apk file.

provided
Provided is for all build type and favlors only at compile time, similar to external-libs in Eclipse, only participates in compiling, not packaging to the final apk.

APK
It will only be packaged into the APK file, not compiled, so you can no longer call the class or method in the jar directly from the code, or you will get an error at compile time.

Test Compile
Test compile is only valid for compilation and compilation of unit test code and final package test apk, which does not work for normal debug or release apk packages.

Debug Compile
Debug compile only for debug mode compilation and final Debug APK package.

Release Compile
Release compile only for release mode compilation and final release APK package.

Differences between two build.gradle configurations in Android project and app

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.