无法实例化自定义视图充气工具android.support.v7.app.AppCompatViewInflater

时间:2018-10-04 15:08:18

标签: android gradle error-handling libraries androidx

我正在尝试在我的应用程序中实现Google登录。

它工作正常,但是当我尝试登录时,我的logcat收到以下错误:

  

2018-10-04 14:55:14.784 16313-16313 /? I / AppCompatDelegate:无法实例化自定义视图充气工具android.support.v7.app.AppCompatViewInflater。退回默认值。       java.lang.ClassNotFoundException:android.support.v7.app.AppCompatViewInflater           在java.lang.Class.classForName(本机方法)           在java.lang.Class.forName(Class.java:453)           在java.lang.Class.forName(Class.java:378)           在android.support.v7.app.AppCompatDelegateImpl.a(:com.google.android.gms @ 13280019 @ 13.2.80(040400-211705629):1)           在android.support.v7.app.AppCompatDelegateImpl.onCreateView(:com.google.android.gms @ 13280019 @ 13.2.80(040400-211705629):1)           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)           在android.view.LayoutInflater.inflate(LayoutInflater.java:492)           在android.view.LayoutInflater.inflate(LayoutInflater.java:423)           在android.view.LayoutInflater.inflate(LayoutInflater.java:374)           在com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1933)           在com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2586)           在com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2659)           在com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2067)           在android.app.ActivityTransitionState.setEnterActivityOptions(ActivityTransitionState.java:160)           在android.app.Activity.performCreate(Activity.java:7016)           在android.app.Activity.performCreate(Activity.java:7000)           在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)           在android.app.ActivityThread.-wrap11(未知来源:0)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1589)           在android.os.Handler.dispatchMessage(Handler.java:106)           在android.os.Looper.loop(Looper.java:164)           在android.app.ActivityThread.main(ActivityThread.java:6494)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)        由以下原因引起:java.lang.ClassNotFoundException:在路径:DexPathList [[zip文件“ /system/framework/com.android.media.remotedisplay.jar”,上找不到类“ android.support.v7.app.AppCompatViewInflater”, zip文件“ /system/framework/com.android.location.provider.jar”、zip文件“ /data/app/com.google.android.gms-mJ0x6f9TEv9BnQUq-xGhTw == / base.apk”],nativeLibraryDirectories = [ /data/app/com.google.android.gms-mJ0x6f9TEv9BnQUq-xGhTw==/lib/arm64,/data/app/com.google.android.gms-mJ0x6f9TEv9BnQUq-xGhTw==/base.apk!/lib/arm64 -v8a,/ system / lib64,/ vendor / lib64]]           在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)           在java.lang.ClassLoader.loadClass(ClassLoader.java:379)           在java.lang.ClassLoader.loadClass(ClassLoader.java:312)           在java.lang.Class.classForName(本机方法)           在java.lang.Class.forName(Class.java:453)           在java.lang.Class.forName(Class.java:378)           在android.support.v7.app.AppCompatDelegateImpl.a(:com.google.android.gms @ 13280019 @ 13.2.80(040400-211705629):1)           在android.support.v7.app.AppCompatDelegateImpl.onCreateView(:com.google.android.gms @ 13280019 @ 13.2.80(040400-211705629):1)           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)           在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)           在android.view.LayoutInflater.inflate(LayoutInflater.java:492)           在android.view.LayoutInflater.inflate(LayoutInflater.java:423)           在android.view.LayoutInflater.inflate(LayoutInflater.java:374)           在com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1933)           在com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2586)           在com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2659)           在com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2067)           在android.app.ActivityTransitionState.setEnterActivityOptions(ActivityTransitionState.java:160)           在android.app.Activity.performCreate(Activity.java:7016)           在android.app.Activity.performCreate(Activity.java:7000)           在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)           在android.app.ActivityThread.-wrap11(未知来源:0)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1589)           在android.os.Handler.dispatchMessage(Handler.java:106)           在android.os.Looper.loop(Looper.java:164)           在android.app.ActivityThread.main(ActivityThread.java:6494)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)           com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

我正在使用新的AndroidX库,并且实现了以下依赖关系:

implementation 'androidx.appcompat:appcompat:1.0.0'

我还更改了 gradle.properties ,以使Android知道我正在使用新的AndroidX库:

# Default properties
org.gradle.jvmargs=-Xmx1536m

# Android X properties
android.useAndroidX=true
android.enableJetifier=true

通过修改 gradle.properties ,所有其他依赖项都应使用新的AndroidX库,对吗?为什么要尝试使用旧的V7库?那我该如何解决这个问题呢?


编辑

这是我的礼物:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId 'my.package.name'

        versionName '1.0.0'
        versionCode 1

        minSdkVersion 16
        targetSdkVersion 28

        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.0'

    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.2.71'
}

2 个答案:

答案 0 :(得分:0)

我不认为从logcat进行堆栈跟踪是您面临的实际问题,因为该问题属于信息(I)类型,但不是错误。我认为您可能还缺少其他错误。尝试使用adb -d logcat -s <ClassNameWhichCanThrowError>查看实际错误,或深入研究logcat以查找E / ClassNameWhichCanThrowError类型的任何错误

答案 1 :(得分:0)

我遇到了同样的问题,但是我发现了另一个日志,即google登录失败。 所以,我回去检查问题出在哪里。 最后,这仅仅是因为我没有提供Firebase SHA-1密钥(调试)。 也许您可以尝试相同的功能。