1.问题描述
一运行项目就报一堆的错:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fendo.cn.xfendo/com.BootView.activity.WelcomeActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class xhs.com.view.ParentViewPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2656)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.access$800(ActivityThread.java:180)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5826)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1109)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:875)
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class xhs.com.view.ParentViewPager
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
at android.view.LayoutInflater.inflate(LayoutInflater.java:510)
at android.view.LayoutInflater.inflate(LayoutInflater.java:420)
at android.view.LayoutInflater.inflate(LayoutInflater.java:371)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:437)
at android.app.Activity.setContentView(Activity.java:2205)
at com.BootView.activity.WelcomeActivity.onCreate(WelcomeActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6117)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.access$800(ActivityThread.java:180)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5826)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1109)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:875)
Caused by: java.lang.ClassNotFoundException: Didn't find class "xhs.com.view.ParentViewPager" on path: DexPathList[[zip file "/data/app/com.example.fendo.cn.xfendo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.fendo.cn.xfendo-1/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:577)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
at android.view.LayoutInflater.inflate(LayoutInflater.java:510)
at android.view.LayoutInflater.inflate(LayoutInflater.java:420)
at android.view.LayoutInflater.inflate(LayoutInflater.java:371)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:437)
at android.app.Activity.setContentView(Activity.java:2205)
at com.BootView.activity.WelcomeActivity.onCreate(WelcomeActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6117)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.access$800(ActivityThread.java:180)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5826)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1109)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:875)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "xhs.com.view.ParentViewPager" on path: DexPathList[[dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-support-annotations-24.2.1_0c52a843b9f6c36748569b9c90eef5f45d7dad69-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-library-2.4.0_96a78d5cacaa442f096467ffefe93d4a9dac6aa9-classes.dex", dex file "/data/data/com.example.fendo.cn.xfendo/files/instant-run/dex/slice-i
09-30 12:52:36.452 1781-1894/? E/CellLocation: create GsmCellLocation
看到这句:
Caused by: java.lang.ClassNotFoundException: Didn't find class "xhs.com.view.ParentViewPager" on path: DexPathList[[zip file "/data/app/com.example.fendo.cn.xfendo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.fendo.cn.xfendo-1/lib/arm64, /vendor/lib64, /system/lib64]]
找不到:xhs.com.view.ParentViewPager类
2.解决方法
原因是我在xml布局文件中引用了一个不存在的类。:
类的路径写错了
把路径改了就行了