美文网首页
ButterKnife不同版本配置

ButterKnife不同版本配置

作者: Everglow_111 | 来源:发表于2019-06-16 19:54 被阅读0次

    7.0.1版本

    compile 'com.jakewharton:butterknife:7.0.1'
    
    Android studio3.0以上版本需要另外配置
    annotationProcessor 'com.jakewharton:butterknife:7.0.1'
    
    如果还报如下错
    Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  Please add them to the annotationProcessor configuration.
      - butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
    Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.
    See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
    
    需要在主module 配置如下信息,注意 主module
     defaultConfig {
             ····
            javaCompileOptions {
                annotationProcessorOptions {
                    includeCompileClasspath = true
                }
            }
        }
    

    目前7.x版本已无法使用(2019.8.21)

    8.0.1版本

    module
    apply plugin: 'com.android.application'
    apply plugin: 'com.neenbedankt.android-apt'
    
      ···
      
    dependencies {
        compile 'com.jakewharton:butterknife:8.0.1'
        apt 'com.jakewharton:butterknife-compiler:8.0.1'
    }
    
    project
    dependencies {
              ···
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        }
    }
    

    8.5.1版本

    module
    apply plugin: 'com.android.library'
    apply plugin: 'com.jakewharton.butterknife'
       ···
    dependencies {
      compile 'com.jakewharton:butterknife:8.5.1'
      annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    }
    
    project
    dependencies {
              ···
            classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
        }
    }
    

    版本越高反而越复杂,是为了自由灵活考虑,不过真的好坑!

    相关文章

      网友评论

          本文标题:ButterKnife不同版本配置

          本文链接:https://www.haomeiwen.com/subject/xctnfctx.html