KeyEventCompat not supported at build KeyEventCompat not supported at build android android

KeyEventCompat not supported at build


change this

if (KeyEventCompat.hasNoModifiers(event)) {    handled = arrowScroll(FOCUS_FORWARD);} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {    handled = arrowScroll(FOCUS_BACKWARD);}

to

if (event.hasNoModifiers()) {    handled = arrowScroll(FOCUS_FORWARD);} else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {    handled = arrowScroll(FOCUS_BACKWARD);}

KeyEventCompat class was deprecated in API level 26.0.0


Since you are supporting API 19+, change your KeyEventCompat calls to KeyEvent calls. You should be able to get comparable functionality at that API level.


I resolved this KeyEventCompat issue by adding this line to the app's build gradle (Above dependencies)

configurations.all {    exclude group: 'com.google.code.gson'    resolutionStrategy.eachDependency { DependencyResolveDetails details ->        def requested = details.requested        if (requested.group == 'com.android.support') {            if (!requested.name.startsWith("multidex")) {                details.useVersion '26.0.2'            }        }    }}