25

In Android studio in the "module settings" in the Dependencies tab you can select a scope for your library files. What is the difference between "compile" and "provided"?

qryckbosch
  • 847
  • 1
  • 9
  • 10

3 Answers3

38

compile includes the library in your final APK, while provided doesn't; provided is a compile-time-only dependency.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
0

Gradle v3.0 includes next changes:

compile -> api - exposes dependency for consumer

provided -> compileOnly - is compile time dependency(not included into binary and isn't available in runtime) that is why it allows you to minify the size of final binary. Usually is used for annotation processor

[Read more]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
0

What to say? To put it bluntly, compile or api will exist during compilation and be packaged into the final project, and it can be transmitted to child dependencies for use. provided only exists during compilation and does not exist when packaged into the final project. If there is no other place to continue to provide dependencies after packaged into the final project, an error will be reported, It is generally used to develop third-party jar packages, etc.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 05 '22 at 15:37