HoloEverywhere xml解析错误/应用程序崩溃

时间:2012-12-09 08:28:41

标签: android parsing android-xml android-logcat android-holo-everywhere

出于某种原因,我在使用HoloEverywhere时遇到此错误。我的应用程序在创建时崩溃,我的xml布局不会显示低于3.0。这是我的xml错误。

Failed to configure parser for C:\Users\Akhil\HoloEverywhere\hololib\res\color\secondary_text_holo_light.xml
Failed to configure parser for C:\Users\Akhil\HoloEverywhere\hololib\res\drawable\background_cache_hint_selector_holo_light.xml
Failed to configure parser for C:\Users\Akhil\HoloEverywhere\hololib\res\color\primary_text_holo_light.xml
Exception details are logged in Window > Show View > Error Log

这是我的logcat。它引用了我的活动onCreate的第57行的错误。第57行膨胀xml文件。这只发生在HoloEverywhere。请帮助!

12-09 03:01:20.893: E/AndroidRuntime(327): FATAL EXCEPTION: main
12-09 03:01:20.893: E/AndroidRuntime(327): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sample/com.example.sample.CourseListActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.os.Looper.loop(Looper.java:123)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-09 03:01:20.893: E/AndroidRuntime(327):  at java.lang.reflect.Method.invokeNative(Native Method)
12-09 03:01:20.893: E/AndroidRuntime(327):  at java.lang.reflect.Method.invoke(Method.java:521)
12-09 03:01:20.893: E/AndroidRuntime(327):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-09 03:01:20.893: E/AndroidRuntime(327):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-09 03:01:20.893: E/AndroidRuntime(327):  at dalvik.system.NativeStart.main(Native Method)
12-09 03:01:20.893: E/AndroidRuntime(327): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:278)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:263)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:258)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:253)
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.app.Activity.setContentView(Activity.java:242)
12-09 03:01:20.893: E/AndroidRuntime(327):  at com.example.sample.CourseListActivity.onCreate(CourseListActivity.java:57)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-09 03:01:20.893: E/AndroidRuntime(327):  ... 11 more
12-09 03:01:20.893: E/AndroidRuntime(327): Caused by: java.lang.ClassNotFoundException: Could not find class: fragment
12-09 03:01:20.893: E/AndroidRuntime(327):  at org.holoeverywhere.LayoutInflater.onCreateView(LayoutInflater.java:318)
12-09 03:01:20.893: E/AndroidRuntime(327):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
12-09 03:01:20.893: E/AndroidRuntime(327):  ... 21 more

3 个答案:

答案 0 :(得分:0)

错误日志说

Could not find class: fragment

Fragments要求API级别11或更高级别:)

如果您想在API上使用Fragments< 11你需要使用Support Library包。

答案 1 :(得分:0)

看起来这已在HoloEverywhere 1.4.1中修复:https://github.com/ChristopheVersieux/HoloEverywhere/issues/

更新到1.4.1是否为您解决了问题?

答案 2 :(得分:0)

尝试以编程方式添加片段。 也就是说,你的xml应该只有布局'content'和onCreate:

if (savedInstanceState == null) {
    // Add the fragment on initial activity setup
    MyFragment myFragment = new MyFragment();
    getSupportFragmentManager().beginTransaction().
         add(R.id.content, myFragment).commit();
}