Android -Gradle dependent change

android studio version after upgrading to version 3.xx, gradle so what changed?

Gradle dependent change

3.0 ago After 3.0 Explanation For work
compile implem-entation Dependency on modules are available at compile time, and only available to consumers in the run-time module. For the construction of large multi-project implementation instead of using api / compile can significantly reduce build time, because it can reduce the amount of the project to build the system needs to be recompiled. Most applications and test modules should use this configuration. Use implementation-dependent way to project or library, the library at compile time, only for the current module visible, not visible to the other module.
compile api Dependency on modules are available at compile-time and runtime also available to consumers and the module at compile time. This configuration is similar to the behavior compile (now deprecated), under normal circumstances, you should only use it in the library module. Application module should use the implementation, unless you want to open its API to the individual test modules. Use api way to rely project or library that can be visible to other module at compile and run time.
provided compile-Only Dependency on module is available only at compile time, and its consumers is not available at compile or run time. This behavior is similar to the configuration provided (now deprecated). Use compileOnly way to depend on the project or library that can be used effectively only at compile time.
apk runtime-Only Module and its dependencies are available to consumers only at run time. This configuration behaves like apk (now deprecated). Use runtimeOnly way to rely project or library, which is available only at run time effective.
3.0 front-dependent manner After the 3.0-dependent manner
compile implemention/api
provided compileOnly
apk runtimeOnly
testCompile testImplemention
debugompile debugImplemention
releaseCompile releaseImplemention

Dependent configuration instruction Gradle

  • implementation (compile): this only inside the module, which depends on the content module is not exposed to the outside.
  • api (compile): and compile
    action, like the current module will be exposed to other module content on which it relies. Use this method relies on libraries will be involved in compiling and packaging.
  • compileOnly (provided): Use this mode dependent libraries only valid at compile time, not involved in packaging.
  • runtimeOnly (apk): Use this mode dependent libraries to participate only when packaged generated apk will not participate in compile time.
  • testImplementation (testCompile): Only valid when compiling test code and the final unit testing packaged apk.
  • debugImplementation (debugCompile): Only valid when compiling debug mode and debug apk final package.
  • releaseImplementation (releaseCompile): only for packaged compilation Release mode and final Release apk.

The difference between implementation and api

  • implementation: This command compiles dependence, the project has dependent projects will not have access to any program that relies on the use of the command compiled, which is hidden inside the dependent, not on external public, does not have a dependent transitive . gradle build faster than api.
  • api: equivalent to compile the instruction, the operation command modifies the external interface, all dependent module and module need to be recompiled, having dependency transitive. gradle build slower than implementation.

Project build.gradle
Here Insert Picture Description

  • buildscript: gradle used to load the script needs to use its own resources, including the resource can declare dependencies, third-party plug-ins, maven repository address, etc.
  • repositories for downloads of source code repository
  • jcente is a new remote central warehouse, compatible maven central warehouse, and better performance
  • google is google code repository hosting
  • dependencies are generally required to perform gradle tool Gradle
  • classpath execution gradle tools needed to address, version numbers generally consistent with the studio version
  • allproject is the configuration of the entire project, such as the difference between repositories and above buildscript of allproject in that: the former allproject entire project itself is dependent on need, which is required to perform gradle script dependent (Gradle plugin), respectively, and the corresponding maven repository plug-dependence
  • When the task clear run gradle clean, defined here to perform task. The task inherited from Delete, delete the root directory of the build directory.
Published 18 original articles · won praise 1 · views 777

Guess you like

Origin blog.csdn.net/aha_jasper/article/details/104769173