java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method

问题描述:
在程序中使用了下面的语句实现绑定Java和Layout

View view = View.inflate(getContext(), R.layout.video_play, this);
ButterKnife.bind(this,view);

但是运行时总出错,报错如下:

 Caused by: java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
        at butterknife.internal.DebouncingOnClickListener.(DebouncingOnClickListener.java:12)

按照提示点开了提示

package butterknife.internal; 
 
import android.view.View;
 
/**
 * A {@linkplain View.OnClickListener click listener} that debounces multiple clicks posted in the
 * same frame. A click on one button disables all buttons for that frame.
 */
public abstract class DebouncingOnClickListener implements View.OnClickListener {
     
  static boolean enabled = true;
 
  private static final Runnable ENABLE_AGAIN = () -> enabled = true;
 
  @Override public final void onClick(View v) {
     
    if (enabled) {
     
      enabled = false;
      v.post(ENABLE_AGAIN);
      doClick(v);
    }
  }
 
  public abstract void doClick(View v);
}

其中 private static final Runnable ENABLE_AGAIN = () -> enabled = true 使用了Java8的新特性。


解决方法:
build.gradle中添加以下代码:

android {

······

compileOptions{
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}
重新编译问题就解决了!

你可能感兴趣的:(Android,android,android,studio)