java - Android:Gradle 编译错误期望元素值是常量表达式 - 功能模块

标签 java android android-jetpack android-instant-apps

这是我的第一个多模块项目。

此登录 Activity 存在于功能模块中,该模块从基本功能模块获取许多依赖项。

在将 @BindView 与 TextInputEditText 和 Button 一起使用的行上,我收到错误 错误:元素值必须是常量表达式

此外,我注意到缺少 R 类的导入,但没有一个 R.id. 是红色的。这是为什么?

enter image description here

最佳答案

功能模块与库模块类似。一旦您从应用程序模块转移到库/功能模块,您的 R 类字段就不再是最终常量。这就是问题发生的原因。要解决此问题,您需要切换到 Butterknife 的 R2 类。

更多信息请参见以下链接:

关于java - Android:Gradle 编译错误期望元素值是常量表达式 - 功能模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54838793/

相关文章:

java - Guava 中没有 SortedMultiMap 吗?

android - 我们可以在通知中发送 Firebase ServerValue 时间戳吗?

android - Jetpack 撰写 : Content color of TabRow

java - 如何设置数据绑定(bind)中包含布局的可见性?

java - 如何使用 Selenium 定位不稳定的表元素?

java - Spring Statemachine 状态操作与转换操作

java - 在 writeToParcel 方法中写入 Parcel 中的对象

用于从输入文本中提取关键字的 Java 库

android - 约束布局 : Compound ImageView that stays in parent when text expands

android - 使用导航架构组件时出现错误的动画