Differences among API, compile and implementation in Android studio 3. X

First, in Android studio 3. X, compile is outdated

Replaced by implementation and API

Secondly, compile is completely equivalent to API. In 3. X, you can completely replace compile with API

The difference between implementation and API

Implementation compilation dependencies only apply to the current module. That is, APP module depends on other module,

Third party libraries (such as glide) compiled with implementation in other module only work for other module,

The third-party library (glide) cannot be used in app module;

If other module relies on base module using implementation, base module cannot be used in app module.

For example:

We changed the reference to com. Alibaba. Fastjson: 1.2.6 in other modules to implementation

Then we can't use it in the app module, because implementation only works for the current module

Error: the package com.alibaba.fastjson does not exist

General introduction

Compile (API) is our most commonly used method, and the library we rely on will participate in compilation and packaging.

Provided (compileonly) is only valid at compile time and does not participate in packaging. You can use this method in your own moudle. For example, com.android.support and gson are commonly used by users to avoid conflicts.

Apk (runtimeonly) only participates in packaging when generating APK, not during compilation, and is rarely used.

Testcompile (test implementation) testcompile is only valid when the unit test code is compiled and finally packaged to test APK.

Debugcompile (debug Implementation) debugcompile is only valid when the debug mode is compiled and the final debug APK is packaged.

Release compile (release Implementation) release compile only aims at the compilation of release mode and the final release APK packaging.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>