出于某种原因,每当我尝试启动我的片段时,我都会遇到这些错误:
12-27 16:54:52.345: D/OpenGLRenderer(4506): Enabling debug mode 0
12-27 16:54:53.775: D/AndroidRuntime(4506): Shutting down VM
12-27 16:54:53.775: W/dalvikvm(4506): threadid=1: thread exiting with uncaught exception (group=0x40be4930)
12-27 16:54:53.785: E/AndroidRuntime(4506): FATAL EXCEPTION: main
12-27 16:54:53.785: E/AndroidRuntime(4506): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.twfs.thewholefnshow/info.twfs.thewholefnshow.ILikeWrestlingActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.os.Looper.loop(Looper.java:137)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-27 16:54:53.785: E/AndroidRuntime(4506): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 16:54:53.785: E/AndroidRuntime(4506): at java.lang.reflect.Method.invoke(Method.java:511)
12-27 16:54:53.785: E/AndroidRuntime(4506): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-27 16:54:53.785: E/AndroidRuntime(4506): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-27 16:54:53.785: E/AndroidRuntime(4506): at dalvik.system.NativeStart.main(Native Method)
12-27 16:54:53.785: E/AndroidRuntime(4506): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-27 16:54:53.785: E/AndroidRuntime(4506): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.Activity.setContentView(Activity.java:1881)
12-27 16:54:53.785: E/AndroidRuntime(4506): at info.twfs.thewholefnshow.ILikeWrestlingActivity.onCreate(ILikeWrestlingActivity.java:16)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.Activity.performCreate(Activity.java:5104)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-27 16:54:53.785: E/AndroidRuntime(4506): ... 11 more
12-27 16:54:53.785: E/AndroidRuntime(4506): Caused by: java.lang.NullPointerException: name == null
12-27 16:54:53.785: E/AndroidRuntime(4506): at java.lang.VMClassLoader.findLoadedClass(Native Method)
12-27 16:54:53.785: E/AndroidRuntime(4506): at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:354)
12-27 16:54:53.785: E/AndroidRuntime(4506): at java.lang.ClassLoader.loadClass(ClassLoader.java:491)
12-27 16:54:53.785: E/AndroidRuntime(4506): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
12-27 16:54:53.785: E/AndroidRuntime(4506): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
12-27 16:54:53.785: E/AndroidRuntime(4506): ... 21 more
令我困惑的是,只有在我的平板电脑上运行应用程序时才会发生这种情况,而不是我的手机。我试图完全替换XML,并得到相同的错误。我检查了清单,名称或其他任何内容都没有错误。
关于什么可能导致此错误的任何想法?
答案 0 :(得分:1)
在ILikeWrestlingActivity
类中,您可以扩展xml布局。此xml布局将放置在项目的文件夹res/layout-sw600 or something
中。
在此文件第7行中,您使用的片段没有android:name
属性。
答案 1 :(得分:0)
事实证明这只是XML文件的一个奇怪的错误。我使用不同的文件名制作了一个XML文件的副本,而不是用该文件充实,现在它就像一个魅力。
我不太确定修复了什么,但我已经开始工作了。