AndroidX:Appcompat I:art error android.view.View$OnUnhandledKeyEventListener

As A.L.Flanagan mentioned in a comment the problem is that android.support.v4.view.ViewCompat does not implement View.OnUnhandledKeyEventListener in the new androidx package structure and only implements it starting on API 28 in the support lib structure (at least in version 28.0.0). Therefore the warning appears on devices with API <28 and does not appear on those >=28.

This is the related code in the ViewCompat.class class from the support package structure:

@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);
    }
}

I can not think about any easy fix to solve this warning.

Leave a Comment