前言
解決4.1.1版本butterknife無法使用的問題
適配

上圖中是以前在3.x版本中使用的ButterKnife,但是它并不適配4.1.1版本,所以我們需要下載另一個,如圖:
下載安裝完成后,你就會發現你的ButterKnife還是不能用(狗頭),這時候我們需要改一下插件的路徑,
4.1.1版本的保存路徑和以前版本的不太一樣,3.x及之前的都是保存在用戶根目錄里的,而4.1.1的路徑是在C:\Users\Administrator\AppData\Local\Google\AndroidStudio4.1,AppData是隱藏檔案夾,找不到的直接向檔案資源管理器貼路徑就完事了(Administrator是電腦的名字,Users在C盤中顯示的是‘用戶’),找到下圖的檔案夾,這是studio存放插件的地方,
剪切下圖的jar包

注意!要將檔案夾中下載的其他的ButterKnife全部洗掉,不然會出一些奇奇怪怪的錯誤(具體我也不知道是什么),
將剪切后的jar包移動到下圖的檔案夾(這是你Android Studio的安裝目錄)
做到這你的ButterKnife已經裝好了,只需要再配置一下,在你的專案gradle中加入依賴
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.jakewharton:butterknife:10.2.3'
}
重啟一下studio就可以使用了
補充:butterKnife獲得控制元件空指標問題
將匯入的依賴改為:
api 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
Annotation Processing Tool(APT)即注解處理器
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/239079.html
標籤:其他
