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"?
3 Answers
compile
includes the library in your final APK, while provided
doesn't; provided
is a compile-time-only dependency.

- 79,344
- 24
- 180
- 163
-
I have compile and still the jar is not included in the apk. – Siddharth Apr 29 '16 at 07:43
-
13why are the names screwed up ? compile is suppose to behave like compile and provide like its being provided to the apk right ? – Siddharth May 28 '16 at 18:29
-
1If the final apk does not include the reference package will cause the error? – Qian Zhang Sep 05 '17 at 05:41
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

- 29,217
- 8
- 193
- 205
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.

- 1
- 2
-
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