一、问题如下图所示

ButterKnife在library(moudle)中报“Attribute value must be constant”

Attribute value must be constant 译为:属性值必须为常量

原因:在library里R.id.xxx不再是final类型了,也就是不是常量了,而BindView(int)l里面是需要传入常量。

二、解决方法

1.在项目工程根目录的gradle配置

classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'

如下图所示:

ButterKnife在library(moudle)中报“Attribute value must be constant”

2.在对应的moudle下配置,例如我的moudle是zaqutils

ButterKnife在library(moudle)中报“Attribute value must be constant”

3.在moudle中关联布局的R,写成R2。

注意:进行1和2步骤后需要Rebuild Project(在Android Studio的状态栏中找到并点击Build ——>Rebuild Project),否则找不到R2

ButterKnife在library(moudle)中报“Attribute value must be constant”

到此问题解决完毕。

 

 

 

 

相关文章:

  • 2021-08-15
  • 2022-12-23
  • 2021-04-10
  • 2022-03-10
  • 2021-07-17
  • 2021-11-05
  • 2021-11-20
  • 2021-11-01
猜你喜欢
  • 2019-12-18
  • 2022-12-23
  • 2021-05-20
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
相关资源
相似解决方案