What's the difference between implementation and compile in Gradle?

前端 未结 9 1487
北荒
北荒 2020-11-22 03:01

After updating to Android Studio 3.0 and creating a new project, I noticed that in build.gradle there is a new way to add new dependencies instead of comp

9条回答
  •  遇见更好的自我
    2020-11-22 03:25

    The brief difference in layman's term is:

    • If you are working on an interface or module that provides support to other modules by exposing the members of the stated dependency you should be using 'api'.
    • If you are making an application or module that is going to implement or use the stated dependency internally, use 'implementation'.
    • 'compile' worked same as 'api', however, if you are only implementing or using any library, 'implementation' will work better and save you resources.

    read the answer by @aldok for a comprehensive example.

提交回复
热议问题