本文介绍了java.lang.NoClassDefFoundError的:android.support.v4.view.LayoutInflaterCompatHC在机器人工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  08-25 18:17:40.354 28953-28953 / com.app E / AndroidRuntime:致命异常:主要
        java.lang.NoClassDefFoundError的:android.support.v4.view.LayoutInflaterCompatHC
                在android.support.v4.view.LayoutInflaterCompat$LayoutInflaterCompatImplV11.setFactory(LayoutInflaterCompat.java:42)
                在android.support.v4.view.LayoutInflaterCompat.setFactory(LayoutInflaterCompat.java:79)
                在android.support.v7.app.AppCompatDelegateImplV7.installViewFactory(AppCompatDelegateImplV7.java:812)
                在android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
                在com.app.utils.UIHelper.onCreate(UIHelper.java:28)
                在com.app.DashboardActivity.onCreate(DashboardActivity.java:97)
                在android.app.Activity.performCreate(Activity.java:4465)
                在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
                在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
                在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
                在android.app.ActivityThread.access $ 600(ActivityThread.java:127)
                在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1158)
                在android.os.Handler.dispatchMessage(Handler.java:99)
                在android.os.Looper.loop(Looper.java:137)
                在android.app.ActivityThread.main(ActivityThread.java:4448)
                在java.lang.reflect.Method.invokeNative(本机方法)
                在java.lang.reflect.Method.invoke(Method.java:511)
                在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:823)
                在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
                在dalvik.system.NativeStart.main(本机方法)
 

build.gradle

 安卓{

    compileSdkVersion 23
    buildToolsVersion23.0.0

    defaultConfig {
        的minSdkVersion 14
        targetSdkVersion 23
        的applicationIDcom.app
        multiDexEnabled =真
    }

    buildTypes {

        调试{
            minifyEnabled假
            调试的真
        }
    }

    lintOptions {
        abortOnError假
    }

    packagingOptions {
        不包括META-INF /许可证
        不包括META-INF /注意事项
    }
}

依赖{
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.google.api客户端:谷歌的API客户端:1.20.0
    编译com.google.api客户端:谷歌的API客户端 - 机器人:1.20.0
    编译com.google.api客户端:谷歌API的客户GSON:1.20.0
    编译com.google.apis:谷歌API-服务日历:v3的rev125-1.20.0
    编译com.android.support:appcompat-v7:23.0.0
    编译com.android.support:design:23.0.0
    编译com.google.android.gms:播放服务:7.8.0
}
 

解决方案

您好像已经启用multidex,但你没有使用multidex库。

棒棒堂(API 21)引入multidexing的原生支持,但是对于previous的Andr​​oid版本,你必须使用multidex支持库,以正确地支持multidexing。

首先,依赖添加到您的build.gradle:

 编译com.android.support:multidex:1.0.0
 

其次,您需要启用multidex在应用程序中code。如果你的不可以使用自定义的应用程序类已经,您可以通过注册这样做 MultiDexApplication 在清单类,像这样:

 <应用
    ...
    机器人:名称=android.support.multidex.MultiDexApplication>
    ...
< /用途>
 

如果您使用自定义的应用程序类,应启用multidex在 attachBaseContext()像这样:

  @覆盖
保护无效attachBaseContext(上下文基地){
    super.attachBaseContext(基峰);

    MultiDex.install(本);
}
 

来源:开发应用程序超过65K方法

08-25 18:17:40.354  28953-28953/com.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
        java.lang.NoClassDefFoundError: android.support.v4.view.LayoutInflaterCompatHC
                at android.support.v4.view.LayoutInflaterCompat$LayoutInflaterCompatImplV11.setFactory(LayoutInflaterCompat.java:42)
                at android.support.v4.view.LayoutInflaterCompat.setFactory(LayoutInflaterCompat.java:79)
                at android.support.v7.app.AppCompatDelegateImplV7.installViewFactory(AppCompatDelegateImplV7.java:812)
                at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
                at com.app.utils.UIHelper.onCreate(UIHelper.java:28)
                at com.app.DashboardActivity.onCreate(DashboardActivity.java:97)
                at android.app.Activity.performCreate(Activity.java:4465)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
                at android.app.ActivityThread.access$600(ActivityThread.java:127)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4448)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
                at dalvik.system.NativeStart.main(Native Method)

build.gradle

android {

    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        applicationId "com.app"
        multiDexEnabled = true
    }

    buildTypes {

        debug {
            minifyEnabled false
            debuggable true
        }
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions{
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.api-client:google-api-client:1.20.0'
    compile 'com.google.api-client:google-api-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-gson:1.20.0'
    compile 'com.google.apis:google-api-services-calendar:v3-rev125-1.20.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.google.android.gms:play-services:7.8.0'
}
解决方案

It looks like you have enabled multidex, but you are not using the multidex library.

Lollipop (API 21) introduced native support for multidexing, but for previous versions of Android you must use the multidex support library to properly support multidexing.

First, add the dependency to your build.gradle:

compile 'com.android.support:multidex:1.0.0'

Second, you need to enable multidex in your application code. If you are not using a custom Application class already, you can do so by registering the MultiDexApplication class in your manifest like so:

<application
    ...
    android:name="android.support.multidex.MultiDexApplication">
    ...
</application>

If you are using a custom application class, you should enable multidex in attachBaseContext() like so:

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);

    MultiDex.install(this);
}

Source: Building Apps with over 65k Methods

这篇关于java.lang.NoClassDefFoundError的:android.support.v4.view.LayoutInflaterCompatHC在机器人工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 09:04