如 https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations 中所述,我们现在有 api
和 implementation
。
在 Android 模块中,即 apply plugin: 'com.android.application'
,我们两者都有。
然而,在普通的 Java 模块中,即 apply plugin: 'java'
(由我的 Android 应用程序模块使用),我只能找到 implementation
,但找不到 api
.
因此在其中一个依赖中,我需要使用compile
,而不能使用api
。
api
是否无法在 Java 模块中访问?
最佳答案
你必须使用:
apply plugin: 'java-library'
The key difference between the standard Java plugin and the Java Library plugin is that the latter introduces the concept of an API exposed to consumers.
The plugin exposes two configurations that can be used to declare dependencies:
api
andimplementation
.
关于Java 模块没有 `api` ,必须使用 `compile` ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46111131/