butterknife异常提示:attribute value must be constant


就是因为你的android工程是lib类型的

如:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

这样你在R.id.xxx 取R中变量的时候并非是final类型,所以只能老老实实findviewbyid了!!!

 

***当然想要把R中变量改为final也是可行的,可能需要在打包的过程中利用脚本把Libray的R中字段替换;有兴趣的可以研究下哦!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM