编程知识 cdmana.com

Android solves the problem that Android studio 4.1.1 does not fit butterknife (the problem of getting control but reporting null pointer has been solved)

Preface

 solve 4.1.1 edition butterknife Problems that cannot be used 

adapter

 Insert picture description here
In the picture above, we used to 3.x Used in version ButterKnife, But it doesn't fit 4.1.1 edition , So we need to download another , Pictured : Insert picture description here
After downloading and installing , You'll find out ButterKnife Still can't use ( dog's head ). At this time, we need to change the path of the plug-in .
4.1.1 The save path of the version is different from that of the previous version ,3.x And before are saved in the user's root directory , and 4.1.1 The path is in C:\Users\Administrator\AppData\Local\Google\AndroidStudio4.1,AppData It's a hidden folder , If you can't find it, just paste the path to the file explorer (Administrator It's the name of the computer ,Users stay C It's on the disk ‘ user ’). Find the folder below , This is a studio Where to store the plug-in . Insert picture description here


Cut the jar package
 Insert picture description here
Be careful ! To download other files in the folder ButterKnife Delete all , Otherwise, there will be some strange mistakes ( I don't know exactly what it is ).
After cutting jar Move the package to the folder below ( This is you? Android Studio Installation directory ) Insert picture description here
Do this your ButterKnife It's set up , Just configure it again , In your project gradle Add dependency in



android {
   
   
  compileOptions {
   
   
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
   
   
implementation 'com.jakewharton:butterknife:10.2.3'
}

Restart it studio You can use it

Add :butterKnife Get control null pointer problem

Change the imported dependency to :

 api 'com.jakewharton:butterknife:10.2.3'
 annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

Annotation Processing Tool(APT) Annotation processor

版权声明
本文为[osc_ 81ub7i61]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224102147072g.html

Scroll to Top