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.
android.view.View$OnUnhandledKeyEventListener
Make the changes in your build.gradle (app level) to downgrade to version 27 as below. Then sync and build project. Hopefully it will fix the issue..
compileSdkVersion 27
targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
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.
How to resolve NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
Sometimes after an upgrade, you need to invalidate and clear cache.
There are some known issues in 3.2 so also ensure you are not on Kotlin tools
org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.70
as that causes freeze issues as well.
If that doesn't work, remove your google plugin lines and support libraries, sync and add them again and sync. Sometimes the cache directories just get out of whack.
Related Topics
How to Get an Uri of an Image Resource in Android
Best Practice for Defining Button Events in Android
Blur Background Behind Alertdialog
Android Studio: How to Attach Android Sdk Sources
How to Set Default App Launcher Programmatically
In Android Edittext, How to Force Writing Uppercase
How to Use Onsaveinstancestate() and Onrestoreinstancestate()
Mediaplayer Stutters at Start of Mp3 Playback
Read & Writing Arrays of Parcelable Objects
The Android Emulator Is Not Starting, Showing "Invalid Command-Line Parameter"
Error:Failed to Open Zip File. Gradle's Dependency Cache May Be Corrupt
Android Studio, Suddenly Got Gpu Driver Issue When Running Emulator
How to Block a Mobile Number Call and Message Receiving in Android Application Development
How to Set Custom Font for a Whole Application in Android
Cursor Adapter and SQLite Example