1

I recently updated Android studio to version 3.0. Now in build.gradle all the dependencies are added using the implementation keyword instead of old compile keyword.

dependencies {
     implementation fileTree(include: ['*.jar'], dir: 'libs')
     implementation 'com.android.support:appcompat-v7:25.4.0'
}

But the compile keyword still works. What is the difference between compile and Implementation?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57

1 Answers1

2

compile has been deprecated so use for libraries use api or implementation

Gradle 3.4 introduced new Java Library plugin configurations that allow you to control whether a dependency is published to the compile and runtime classpaths of projects that consume that library. The Android plugin is adopting these new dependency configurations, and migrating large projects to use them can drastically reduce build times.

implementation

if an implementation dependency changes its API, Gradle recompiles only that dependency and the modules that directly depend on it. Most app and test modules should use this configuration.

api

When a module includes an api dependency, it's letting Gradle know that the module wants to transitively export that dependency to other modules, so that it's available to them at both runtime and compile time. This configuration behaves just like compile (which is now deprecated), and you should typically use this only in library modules. That's because, if an api dependency changes its external API, Gradle recompiles all modules that have access to that dependency at compile time

Read more from new dependency configurations

AskNilesh
  • 58,437
  • 15
  • 99
  • 129