zoukankan      html  css  js  c++  java
  • Android--我的Butterknife黄油刀怎么找不到控件了!!!

    1,首先说一下Butterknife这个插件真的挺好用的,不过最近几天在写demo的时候发现总是出现绑定的view是空的,当时着急写代码,也没有深究一下,直接手工findViewbyid了,今天下午写demo的时候还是出现这个问题,就想好好的研究一下了,

    一看不知道,原来是版本升级了,以前一直用的是7.0的版本

    compile 'com.jakewharton:butterknife:7.0.1'
    

    但是最近几次都是用的8.0的版本

    compile 'com.jakewharton:butterknife:8.0.1'
    

    然后果断去github上看了下官方文档,果然,麻蛋,引用都变了,所以以后变成这样了

    首先在工程的gradle的这样写

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.1.0'
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //主要是这句话
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    再看一下我们在app的gradle的使用,有了些许变化

    apply plugin: 'com.android.application'
    apply plugin: 'com.neenbedankt.android-apt'  //这儿要添加
    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.0"
    
        defaultConfig {
            applicationId "com.qianmo.myview2"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:25.0.0'
        compile 'com.android.support:design:25.+'
        compile 'com.android.support:recyclerview-v7:25.+'
        compile 'com.android.support:cardview-v7:25.+'
        compile 'com.balysv:material-ripple:1.0.2'
        //下面两句就是依赖了
        compile 'com.jakewharton:butterknife:8.2.1'
        apt 'com.jakewharton:butterknife-compiler:8.2.1'
        
    }
    

    这样我们就又可以使用了······

      

     

      

  • 相关阅读:
    白盒测试笔记之:Junit 单元测试以及测试覆盖率
    Bootstrap+JSP实例学习笔记一.简单的带登录功能的首页
    一位普通测试人2018年简单回顾
    Web API学习笔记(Python实现)
    web安全测试--sql注入攻击
    电源分配系统及电源完整性
    FPGA Timing笔记
    使用arm开发板搭建无线mesh网络(二)
    使用arm开发板搭建无线mesh网络(一)
    arm tiny6410双网卡桥接问题
  • 原文地址:https://www.cnblogs.com/wjtaigwh/p/6043274.html
Copyright © 2011-2022 走看看