butterknife 8.2.1使用

1396 ワード

一、プロジェクトのbuild.gradleファイルを開き、buildscriptを修正し、追加する
classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8’

追加後のコードは次のとおりです.
dependencies {    
    classpath 'com.android.tools.build:gradle:2.0.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
}

二、Moduleのbuild.gradleファイルを開き、追加する
applyplugin:'android-apt'追加後のコードは以下の通りです.
apply plugin: 'com.android.application'
apply plugin: 'android-apt'

三、Moduleのbuild.gradleファイルdependenciesに追加
apt'com.jakewharton:butterknife-compiler:8.2.1'追加後のコードは次のとおりです.
dependencies {    
    compile fileTree(include: ['*.jar'], dir: 'libs')testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.jakewharton:butterknife:8.2.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/Android_RTCM_SDK_v1.0.6_rtk_15.jar')
    compile 'com.google.android.gms:play-services-appindexing:8.1.0'
    compile files('libs/nagrand-jar-with-dependencies.jar')
    apt 'com.jakewharton:butterknife-compiler:8.2.1'
}