コードでAppBarLayoutとNestedScrollviewを使用していますが、エラーが発生します。コードは正常にコンパイルされますが、スタックトレースでクラッシュします
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で開発します。提案に感謝します。
プロジェクトにGoogleデザインサポートライブラリが含まれているかどうかを確認します。このようにアプリレベルのGradleファイルに含めることができます-
compile 'com.Android.support:design:23.3.0'
また、gradelにサポートライブラリを追加する前に、ターゲットのSDKバージョンを確認してください
例えば:
ターゲットSDK = 25の場合
その場合、サポートライブラリはcom.Android.support:design:25.4.0になります。または、minSdkVersionとtargetSdkVersionの間にある場合もあります。