1. 程式人生 > >Android studio異常Class not found using the boot class loader; no stack available

Android studio異常Class not found using the boot class loader; no stack available

01-16 01:50:58.298 9057-9057/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.example.administrator.artisanhome, PID: 9057
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.artisanhome/com.example.administrator.artisanhome.activity.MainActivity}: android.view.InflateException: Binary XML file
line #15: Error inflating class com.bigkoo.convenientblanner.ConvenientBanner at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360
) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102
) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.bigkoo.convenientblanner.ConvenientBanner at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at com.example.administrator.artisanhome.fragments.FirstPagerFragment.onCreateView(FirstPagerFragment.java:23) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298) at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1998) at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:181) at com.example.administrator.artisanhome.activity.BaseActivity.onStart(BaseActivity.java:45) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220) at android.app.Activity.performStart(Activity.java:5949) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bigkoo.convenientblanner.ConvenientBanner" on path: DexPathList[[zip file "/data/app/com.example.administrator.artisanhome-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 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:571) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at com.example.administrator.artisanhome.fragments.FirstPagerFragment.onCreateView(FirstPagerFragment.java:23) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298) at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1998) at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:181) at com.example.administrator.artisanhome.activity.BaseActivity.onStart(BaseActivity.java:45) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220) at android.app.Activity.performStart(Activity.java:5949) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Suppressed: java.lang.ClassNotFoundException: com.bigkoo.convenientblanner.ConvenientBanner 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) ... 32 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

這個意思是說沒有找到根類載入器,然後我又往上看異常資訊,發現了貓膩

這個
Binary XML file line #15: Error inflating class com.bigkoo.convenientblanner.ConvenientBanner

然後我又看了下這個ConvinientBanner依賴已經匯入了,怎麼還報錯,好吧既然這樣,我把這個控制元件又寫了一遍

<com.bigkoo.convenientbanner.ConvenientBanner
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:id="@+id/banner_cb"
        app:canLoop="true"></com.bigkoo.convenientbanner.ConvenientBanner>

因為這個控制元件我是從別的Activity複製過來的,有可能導致R地址錯誤,改過果然沒事了

對這個問題,網上說重啟,也是可以,前提是你確保異常資訊你都排除掉了.我的異常解決了,可能大家都各不一樣,也有可能lib包未匯入等等,大家還是要細心.