【发布时间】:2020-05-14 03:41:29
【问题描述】:
当我在模拟器上运行此应用程序时,它会崩溃。导致它崩溃的行是v.getBackground().setColorFilter。
但是,在实际设备上测试应用程序时没有问题。
button.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
v.getBackground().setColorFilter(new BlendModeColorFilter(0xe0f47521, BlendMode.SRC_ATOP));
v.invalidate();
break;
}
case MotionEvent.ACTION_UP: {
v.getBackground().clearColorFilter();
v.invalidate();
break;
}
}
return false;
}
});
【问题讨论】:
-
The
BlendModeColorFilterclass 直到 API 级别 29 才引入。尝试在以前的版本上使用它会抛出该异常。 -
@MikeM。我只是好奇,为什么在实际设备上调试时没有相同的错误?只有在使用模拟器时才会崩溃。
-
我猜设备是API级别29或以上,但模拟器是旧版本。
-
@MikeM。你是对的。感谢您的帮助。
标签: java android noclassdeffounderror