Android ButterKnife 8.6.0不工作

Android ButterKnife 8.6.0不工作,android,nullpointerexception,butterknife,Android,Nullpointerexception,Butterknife,我以前使用的是7.0.1,它工作正常,但突然停止工作,在使用变量时出现空指针异常。然后我将其更改为8.6.0 我的代码是这样的 (格拉德尔项目) (应用程序gradle) 内部碎片 public class ScheduleRideFragment extends Fragment { @BindView(R.id.scheduleRideFragApplyCouponButton) Button applyCouponButton; @Nullable @Override public Vie

我以前使用的是7.0.1,它工作正常,但突然停止工作,在使用变量时出现空指针异常。然后我将其更改为8.6.0

我的代码是这样的

(格拉德尔项目)

(应用程序gradle)

内部碎片

public class ScheduleRideFragment extends Fragment {
@BindView(R.id.scheduleRideFragApplyCouponButton)
Button applyCouponButton;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View view = LayoutInflater.from(getActivity()).inflate(R.layout.schedule_ride_fragment_layout, null);
    ButterKnife.setDebug(true);
    ButterKnife.bind(this, view);
    initAndSetListners();
    return view; 
}
private void initAndSetListners() {
applyCouponButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });
 }
}
但是它给了java.lang.NullPointerException(参见日志)

注意:我只发布了相关代码

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/scheduleRideCouponButtonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp"
android:visibility="invisible">
<Button
android:id="@+id/scheduleRideFragApplyCouponButton"
android:layout_width="wrap_content"
android:layout_height="35sp"
android:background="@color/brightGreen"
android:ems="12"
android:text="APPLY COUPON"
android:textColor="@color/textColor" /></LinearLayout></android.support.design.widget.CoordinatorLayout>`
我也看过这些答案,但不起作用 这种情况(碎片和活动)都在发生。我做错什么了吗

无法发布整个计划\u骑行\u片段\u布局.xml代码,因此我只发布相关代码

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/scheduleRideCouponButtonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp"
android:visibility="invisible">
<Button
android:id="@+id/scheduleRideFragApplyCouponButton"
android:layout_width="wrap_content"
android:layout_height="35sp"
android:background="@color/brightGreen"
android:ems="12"
android:text="APPLY COUPON"
android:textColor="@color/textColor" /></LinearLayout></android.support.design.widget.CoordinatorLayout>`

`

Butterknife 8.6.0开始:

(gradle项目)

并仅在build.gradle中保留以下依赖项,如中所述

最后,对于onClickListener()使用Butterknife提供的OnClick注释

@OnClick(R.id.scheduleRideFragApplyCouponButton)
public void onApplyCouponButtonClick(Button button){
}

尝试使用此
LayoutInflater.from(getContext()).flate(R.layout.schedule\u fragment\u layout,container,false)
thnks获得回复@Luca Nicoletti,但它不起作用。请发布schedule\u fragment\u布局。xml@lelloman如果您要获取按钮ID,我已检查了xml中是否存在R.ID.scheduleefragment\u-agapplycouponbutton。在两天前它运行良好,我没有做任何更改是的,你是对的,你在升级库后做了一个干净的构建吗?先生,你的代码和OP的代码有什么显著的区别?你的代码解决了OP代码的什么问题?@Prokash Sarkar也尝试了这个,但最初它没有给出错误,还有一些字段也像TextView和EditText,它们上出现了一些错误,我想知道它在过去两个月内是否正常工作,为什么停止工作。请将你的xml布局的代码也发布到@Ajeetchoudhary,他保留了官方文档中不推荐的依赖插件。我怀疑可能存在依赖冲突@azizbekianI认为我们使用的是相同的依赖项,但它仍然不起作用
dependencies {
       classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
}
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
@OnClick(R.id.scheduleRideFragApplyCouponButton)
public void onApplyCouponButtonClick(Button button){
}