ClassNotFoundException:找不到类" android.support.design.widget.AppBarLayout"

时间:2016-05-02 09:44:21

标签: android material-design classnotfoundexception

我在我的代码中使用了AppBarLayout和NestedScrollview。但是我收到了一个错误。代码编译成功但与stacktrace崩溃

05-02 17:10:17.255 31335 31335 E AndroidRuntime: FATAL EXCEPTION: main
05-02 17:10:17.255 31335 31335 E AndroidRuntime: Process: com.android.settings, PID: 31335
05-02 17:10:17.255 31335 31335 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{XXXXXXXXXXXXXXXXXXX}: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class android.support.design.widget.AppBarLayout
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.ActivityThread.access$900(ActivityThread.java:153)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5438)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:736)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-02 17:10:17.255 31335 31335 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class android.support.design.widget.AppBarLayout
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.Activity.setContentView(Activity.java:2183)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:6303)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    ... 9 more
05-02 17:10:17.255 31335 31335 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class android.support.design.widget.AppBarLayout
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    ... 18 more
05-02 17:10:17.255 31335 31335 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.AppBarLayout" on path: DexPathList[[zip file "/system/framework/cloud-common.jar", zip file "/system/framework/zxing.jar", zip file "/system/framework/android-support-v13.jar", zip file "/system/framework/protobuf.jar", zip file "/system/priv-app/Settings/Settings.apk"],nativeLibraryDirectories=[/system/priv-app/Settings/lib/arm, /vendor/lib, /system/lib]]
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    ... 22 more
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    Suppressed: java.lang.ClassNotFoundException: android.support.design.widget.AppBarLayout
05-02 17:10:17.255 31335 31335 E AndroidRuntime:        at java.lang.Class.classForName(Native Method)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
05-02 17:10:17.255 31335 31335 E AndroidRuntime:        ... 25 more
05-02 17:10:17.255 31335 31335 E AndroidRuntime:    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我用intellij .thanks开发任何建议。

2 个答案:

答案 0 :(得分:19)

检查您的项目中是否包含Google Design Support Library。您可以将其包含在您的应用级Gradle文件中,如下所示 -

compile 'com.android.support:design:23.3.0'

答案 1 :(得分:1)

还要在classl

中添加任何支持库之前检查目标sdk版本

例如:

如果目标sdk = 25

那么您的支持库将是com.android.support:design:25.4.0,或者我们可以在minSdkVersion和targetSdkVersion之间。