简体   繁体   English

我是否需要添加 kapt “com.android.databinding:compiler:$compiler_version” gradle 条目?

[英]Do I need to add kapt “com.android.databinding:compiler:$compiler_version” gradle entry?

Theofficial documentation never mentions adding a dependency for data binding and neither does the sunflower app (which implements best practices) use it. 官方文档从未提及为数据绑定添加依赖项, 向日葵应用程序(实现最佳实践)也没有使用它。

However, everywhere else I look (also here ) I see people mentioning to add the following (but never really explaining):但是,在我看到的其他任何地方(也在此处),我看到人们提到要添加以下内容(但从未真正解释过):

dependencies {
    ...
    kapt "com.android.databinding:compiler:$compiler_version"
}

I found this and my understanding is that the line above will help to reduce the apk size of the app.我发现了这一点,我的理解是上面的行将有助于减少应用程序的 apk 大小。 Is that really the case?真的是这样吗? Are there other benefits or should I just ignore this as the official docs and resources have?是否有其他好处,或者我应该像官方文档和资源一样忽略这一点?

That dependency is automatically added by enabling data binding.通过启用数据绑定会自动添加该依赖项。 I think there were some Kotlin-related problems a few years ago (your linked-to resources are from 2017 and 2018), but they are fixed now.我认为几年前存在一些与 Kotlin 相关的问题(您链接到的资源来自 2017 年和 2018 年),但现在已经修复。 You do not need to add it manually.您不需要手动添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们是否还需要包含`kapt com.android.databinding:compiler` - Do we still need to include `kapt com.android.databinding:compiler` 找不到 com.android.databinding:compiler.3.4.0 - Could not find com.android.databinding:compiler.3.4.0 不起作用:Android Studio 3.2 Canary11 + 3.2.0-alpha11 for kapt with com.android.databinding - Not work: Android Studio 3.2 Canary11 + 3.2.0-alpha11 for kapt with com.android.databinding Gradle找不到com.android.databinding:dataBinder:1.0-rc0 - Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0 Android-如何使用com.android.databinding:dataBinder进行双向绑定? - Android - How to do a bi directional binding with com.android.databinding:dataBinder? 如何在模块(Android studio)中使用com.android.databinding? - How to use com.android.databinding in module(Android studio)? Android Studio 更新 - 无法解析 com.android.databinding - Android Studio update - Failed to resolve com.android.databinding Android-构建失败,数据绑定和gradle 3.2.1的kapt - Android - Build fails with databinding and kapt with gradle 3.2.1 无法解决:com.android.databinding:library:3.1.2 - Failed to resolve: com.android.databinding:library:3.1.2 找不到com.android.databinding:library:3.1.1 - Could not find com.android.databinding:library:3.1.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM