android - Android Gradle - Implementation、releaseImplementation 和 debugImplementation 的区别
问题描述
我在 Android Studio 中有一个 Android 应用程序。我正在使用Gradle Version = 4.6, Android Plugin Version=3.2.1.
. 它有一个应用程序模块(主)和一个库模块。
library
我重命名了模块中的一个类函数。在清理并构建library
模块后跟app
模块后,我在 app 模块中收到此错误:error: cannot find symbol to the renamed class function
下面是我的 build.gradle(app):
android {
...
}
dependencies {
...
releaseImplementation 'com.example.library:1.0.0'
debugImplementation project(':library')
}
如果我将 build.gradle 更改为下面的,那么一切正常。
android {
}
dependencies {
...
implementation project(':library')
}
我想知道 和 之间的区别implementation
,releaseImplementation
以及debugImplementation
如何在我的情况下使用它。
解决方案
implementation
将依赖项应用于所有构建变体。如果您只想为特定的构建变体源集或测试源集声明依赖关系,则必须将配置名称大写并在其前面加上构建变体或测试源集的名称。
例如:如果您必须使用单独的依赖项进行调试、发布和免费构建变体(my-library-debug
和my-library
分别my-library-free
),那么您必须使用debugImplementation
, releaseImplementation
和freeImplementation
如下
debugImplementation 'com.test.package:my-library-debug:1.0'
releaseImplementation 'com.test.package:my-library:1.0'
freeImplementation 'com.test.package:my-library-free:1.0'
注意:在上述情况下,如果您只使用
implementation 'com.test.package:my-library:1.0'
那么你所有的构建,比如调试和自由类型,只会拉my-library
你可能不想要的。
在此处阅读更多内容(您也可以结合产品风格和构建类型,以针对更具体的构建变体):https ://developer.android.com/studio/build/dependencies#dependency_configurations
推荐阅读
- sidr - 用户单击链接时关闭 sidr 菜单
- c# - 当 Parallel.For 尚未完成时,如何处理 WM_PAINT?
- c# - 无法订阅节点 RosSharp C# Unity
- javascript - 为什么 setTimeout 返回数值
- r - 将新列添加到数据框中,它是 for 循环 R 中数据框的名称?
- java - Minecraft - 物品栏上方的信息栏完全人工制作
- formatting - 如何格式化数字向量和字符串向量?(Dyalog APL)
- python - 使用分类报告评估 Keras 模型
- node.js - 具有多个相同结构数据库的猫鼬的最佳实践
- r - GGPlot 2列,只有一些堆叠