Difference between "compile" and "implementation" in gradle file


I added firebase to my project using the wizard that AS provides, but when I added the dependency, it appears differently.

implementation 'com.google.firebase:firebase-auth:11.8.0' 

But another google service compiles in the following way:

compile 'com.google.firebase:firebase-core:11.8.0'

As you can see, only the word changes at the beginning, Now I would like to know the difference between implementation and complle or it is simply a synonym.

When I update the file .gradle , it does not generate an error.

asked by Ashley G. 17.02.2018 в 22:29

2 answers


As of version 3.0 of Gradle, compile is obsolete and you must use api or implementation .

api is used to include dependencies that will be exported by your library's API. implementation is used to include a dependency that will be used internally in your project.

In short, on Android if you use Gradle 3.0 or higher you must use implementation instead of compile .

Gradle will not give you an error if you use compile , but eventually it will be removed and you will have to use if or if implementation .

You can see the documentation here .

answered by 18.02.2018 / 02:15

The main differences that exist between compile and implementation are:

That implementation has many advantages and improvements over compile which are:

  • Faster compilation thanks to reduced classpath size.

  • Fewer recompilations when dependencies change.

  • Note: The compile configuration still exists, but should not be used, as it will not offer the guarantees provided by the api configurations.

    answered by 19.02.2018 в 14:34