android.view.InflateException:二进制XML文件行#2:二进制XML文件行#2:错误膨胀类android.support.design.widget.CoordinatorLayout

时间:2016-04-16 14:48:46

标签: android

尝试在Nexus 5x中运行应用时出现此错误。

下面是堆栈:

04-16 22:41:37.083 23199-23199/au.com... E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: au.com.beewest.natswarehouse, PID: 23199
                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{au.com.beewest.natswarehouse/au.com....MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:148)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                           Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                                              at au.com.beewest.natswarehouse.MainActivity.onCreate(MainActivity.java:26)
                                                                              at android.app.Activity.performCreate(Activity.java:6251)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:148) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5422) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                           Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                              at au.com.beewest.natswarehouse.MainActivity.onCreate(MainActivity.java:26) 
                                                                              at android.app.Activity.performCreate(Activity.java:6251) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:148) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5422) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                           Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/au.com.beewest.natswarehouse-2/base.apk"],nativeLibraryDirectories=[/data/app/au.com.beewest.natswarehouse-2/lib/arm64, /vendor/lib64, /system/lib64]]
                                                                              at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:583)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                              at au.com.beewest.natswarehouse.MainActivity.onCreate(MainActivity.java:26) 
                                                                              at android.app.Activity.performCreate(Activity.java:6251) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:148) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5422) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                            Suppressed: java.lang.ClassNotFoundException: android.support.design.widget.CoordinatorLayout
                                                                              at java.lang.Class.classForName(Native Method)
                                                                              at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                              at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                    ... 22 more
                                                                           Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我的build.gradle

apply plugin: 'com.android.application'

android {     compileSdkVersion 23     buildToolsVersion“23.0.2”

defaultConfig {
    applicationId "au.com...."
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

依赖{     编译fileTree(dir:'libs',包括:['* .jar'])     testCompile'junit:junit:4.12'     编译'org.apache.httpcomponents:httpclient:4.5'     编译'com.loopj.android:android-async-http:1.4.9'     编译'com.android.support:appcompat-v7:23.2.1' }

2 个答案:

答案 0 :(得分:2)

compile 'com.android.support:design:23.2.1'添加到build.gradle以解决

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile 'org.apache.httpcomponents:httpclient:4.5'
   compile 'com.loopj.android:android-async-http:1.4.9'
   compile 'com.android.support:appcompat-v7:23.2.1'
   compile 'com.android.support:design:23.2.1'
}

记得将23.2.1更改为您正在使用的构建版本

答案 1 :(得分:0)

请将您的问题添加到XML布局文件中。 看起来你的布局有问题。