Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewCompat$OnUnhandledKeyEventListener on setContentView

Tags:

android

the error is triggered by the command:

setContentView(R.layout.activity_item_list);

this code was generated by android studio , when creating a new android project using the "master/slave flow"

it seems the layout was rendered but still the errors appear

I/zygote: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
        at void android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, android.support.v4.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
        at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void android.support.v7.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void android.support.v7.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
        at void com.junkradar.junkradar.ItemListActivity.onCreate(android.os.Bundle) (ItemListActivity.java:52)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7009)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7000)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2731)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2856)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1589)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:164)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6494)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/base.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_dependencies_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_resources_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_slice_0_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_slice_1_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_slice_2_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_slice_3_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_slice_4_apk.apk", zip file "/data/app/com.junkradar.junkradar-g7TqmgFV3I4lrTx3ge5E_g==/split_lib_slice_5_apk.apk", zip file "/data/app/com.jun
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at void android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, android.support.v4.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
        at android.view.ViewGroup .....

activity_item_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".ItemListActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/item_list" />
    </FrameLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>

as mentioned, the code is generated automatically by Android Studio 3.2.1 and selecting "Master/Detail Flow" type of Activity

like image 863
Dror Avatar asked Nov 05 '18 19:11

Dror


1 Answers

  1. I stumbled on a github snippet that does the trick

you should paste the following to the bottom of your project's - build.gradle

// This is to fix the errors : java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == "com.android.support") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "26.+"
            }
        }
    }
}
  1. i ended up using the suggestion in the URL below (instead of 1) -

developer.android.com/studio/build/multidex

like image 165
Dror Avatar answered Sep 25 '22 20:09

Dror