为什么 Android 在 Gradle 依赖项中将“编译"配置更改为“实现"配置?

Why Android change #39;compile#39; to #39;implementation#39; configuration in Gradle dependencies?(为什么 Android 在 Gradle 依赖项中将“编译配置更改为“实现配置?)
本文介绍了为什么 Android 在 Gradle 依赖项中将“编译"配置更改为“实现"配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

正如在 Android Studio 3.0 (canary 3.0) 中看到的,我们现在通过声明 implementation 而不是 compile 配置来添加 depedencies.

As seen in Android Studio 3.0 (canary 3.0), we now add depedencies by declaring implementation instead of compile configuration.

// Before
compile 'com.android.support:appcompat-v7:25.3.1'

// Currently
implementation 'com.android.support:appcompat-v7:25.3.1'

我们仍然可以使用compile,但我想明白:

We can still use compile, but I would like to understand:

  • implementationcompile配置有什么区别?
  • 为什么 Android Gradle 构建更改为默认使用 implementation?
  • What is the difference between implementation and compile configuration?
  • Why do Android Gradle build change to use implementation as default?

推荐答案

似乎 compile 已被弃用,apiimplementation 应该改为使用.根据 Java 库插件 - Gradle 用户指南 3.5 版:

It seems like compile has been deprecated and api or implementation should be used instead. According to The Java Library Plugin - Gradle User Guide Version 3.5:

compile 配置仍然存在,但不应使用,因为它无法提供 apiimplementation 配置提供的保证.

The compile configuration still exists but should not be used as it will not offer the guarantees that the api and implementation configurations provide.

这篇关于为什么 Android 在 Gradle 依赖项中将“编译"配置更改为“实现"配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)