qryckbosch
qryckbosch

Reputation: 857

What is the difference between "provided files" and "compile"

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"?

Upvotes: 25

Views: 11768

Answers (3)

蜀汉玫瑰
蜀汉玫瑰

Reputation: 1

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.

Upvotes: 0

yoAlex5
yoAlex5

Reputation: 34175

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]

Upvotes: 0

Scott Barta
Scott Barta

Reputation: 80010

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

Upvotes: 38

Related Questions