Rejecting re-init on previously-failed class java.lang.Class

运行项目报错如下,提示找不到OnUnhandledKeyEventListener。

2019-05-16 10:56:58.801 6012-6012/? I/zygote64: Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.support.v4.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.support.v7.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.support.v7.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.support.v7.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void com.fuxi.mediaplayer.NormalMediaplayerActivity.onCreate(android.os.Bundle) (NormalMediaplayerActivity.java:78)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7168)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7159)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2736)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2861)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1594)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.os.Looper.loop() (Looper.java:164)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6539)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
2019-05-16 10:56:58.802 6012-6012/? I/zygote64:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)

以下是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28  // 编译版本28
    defaultConfig {

        minSdkVersion 21
        targetSdkVersion 28  // 目标版本28
        versionCode 1
        versionName "1.0"

        flavorDimensions "1"
        multiDexEnabled true
    }
    ......
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'  // appcompat包版本28
}

解决方案

  1. 不使用AppCompat包
  2. 如果一定要使用,保证AppCompat包的版本要和目标设备的系统版本对应。我的编译版本是28,但是我的目标设备版本是26,所以就出现了找不到类的异常。所以将三处28修改为26即可。

你可能感兴趣的:(Android,Bug)