解决ButterKnife在library中报“Attribute value must be constant”

2019-04-09 17:06:15

Android开发,在library中使用ButterKnife,需要做一些配置否则会遇到一些问题。
我开发中遇到的问题是,通过@BindView(R.id.xxx)查找控件时,会报“Attribute value must be constant”的异常。
解决方案如下:

  1. 在根目录build.gradle文件的dependencies目录下添加如下:
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'

  2. 在module的build.gradle文件的顶部加入apply plugin: 'com.jakewharton.butterknife'

  3. 在module的build.gradle文件的dependencies目录下添加如下:
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

  4. 在module中使用R2代替R来findViewById即可.
    @BindView(R2.id.xxx)




  • 2020-12-07 22:02:44

    intellij idea远程开发的几个想法

    我之前是用idea上面自带的stfp来做的本地开发同步到linux服务器编译,但是我发现这个如果多个客户端同时开发,或者多个同事一起开发,服务器上的就不能更新到本地。是不能增量更新到本地,必须全部下载,比对下载也行,但是工程量打了就特别慢。

  • 2020-12-07 22:06:13

    System Extension Blocked - warning

    After upgrading your macOS computer to High Sierra 10.13.4 or higher (starting in April 2018), you may see a message about a System Extension Blocked. At Williams we have seen this warning appear for these programs:

  • 2020-12-08 08:57:12

    win10上使用win-sshfs

    首先在GitHub上下载DokanSetup-1.0.5.1000和WinSSHFS-1.6.1.13-devel 注意:Dokan不能使用最新的版本,得使用1.0.5版本。要不win-sshfs会报Dokan版本错误的问题。(win10版本)

  • 2020-12-08 11:51:54

    Ubuntu安装Node.js和npm

    Node.js是基于Chrome的JavaScript构建的跨平台JavaScript运行时环境,npm是Node.js的默认程序包管理器,也是世界上最大的软件注册表。本篇文章展示了三种在Ubuntu 20.04服务器上安装Node.js和npm的方法。

  • 2020-12-08 17:13:57

    nvm卸载、安装node和npm

    1、node.js、nvm、 npm (1)在cmd中输入`where node`找到node长须所在位置进行删除 (2)确保计算机-环境变量删除相关引用 (3)在cmd中输入`node -v` ,得到以下结果,删除成功