错误配置 'compile' 已过时,已替换为 'implementation' 和 api

Error Configuration 'compile' is obsolete and has been replaced with 'implementation' and api

最近我用构建工具和 API 更新了 android 工作室。

在同步当前项目时出现如下错误: “错误配置 'compile' 已过时,已被“实现和 'api' 取代。 如何修复此错误。

compile 配置已弃用,因此您必须改用 implementation 配置。在依赖项下,在您的应用程序模块的 build.gradle 中,将 compile 替换为 implementation

我找到了这个问题的完整解决方案。这是对 build.gradle 文件中更改的简单解释。

  • 你必须用 api 替换 compile 在你使用任何 api ref 的地方。喜欢:排球,GitHub依赖。强文
  • 你必须将 compile 替换为 implementation ,无论你在哪里使用 android 库,如 play-services-maps, appcompat-v7 等

ref