问题:发生在setContentView(getLayoutResId),简单的布局,设备是8.0的,没有任何问题,奇怪的是居然没有奔溃?!
对于Google每次对AS或SDK升级都会产生一些幺蛾子事见怪不怪了,出现上述问题,是google对androidx 包结构目录做了一些改动
android.support.v4.view.ViewCompat 中没有实现View.OnUnhandledKeyEventListener,只在支持lib结构中的API 28上开始实现(至少在版本28.0.0中)。因此,警告会出现在API <28的设备上,并且不会出现在> = 28的设备上。
@RequiresApi(28)
private static class OnUnhandledKeyEventListenerWrapper implements OnUnhandledKeyEventListener {
private ViewCompat.OnUnhandledKeyEventListenerCompat mCompatListener;
OnUnhandledKeyEventListenerWrapper(ViewCompat.OnUnhandledKeyEventListenerCompat listener) {
this.mCompatListener = listener;
}
public boolean onUnhandledKeyEvent(View v, KeyEvent event) {
return this.mCompatListener.onUnhandledKeyEvent(v, event);
}
}
最后附上stack连接,为此问题做一个记录
https://stackoverflow.com/questions/51782548/androidxappcompat-iart-error-android-view-viewonunhandledkeyeventlistener/52954286#52954286