android studio3.0.1 配置butterknife
阿新 • • 發佈:2019-01-10
本文僅做記錄,不分析。
1、下載安裝。
file-->settings-->plugins-->butterknife。如果沒有則進行下載。
2、建立依賴 新增butterknife
3、如果搜尋不到,需要手動寫build.gradle檔案。
專案的gradle,新增mavenCentral()、、、classpath...
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { //資源庫 repositories { google() jcenter() mavenCentral() //for butterknife } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
app的gradle下的操作
apply plugin: 'com.jakewharton.butterknife'
dependencies {
//ButterKnife依賴
implementation 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
然後就可以使用了。
測試:在Activity中,使用註解@BindView。如果出現自動提示,則表示成功。
混淆:
-keep class butterknife.** { *; } -dontwarn butterknife.internal.** -keep class **$$ViewBinder { *; } -keepclasseswithmembernames class * { @butterknife.* <fields>; } -keepclasseswithmembernames class * { @butterknife.* <methods>; }