ActionBarView Inflate Crash

时间:2013-11-10 00:35:45

标签: android android-layout android-actionbar android-inflate android-actionbar-compat

我收到了一些用户的崩溃报告。他们使用的是三星SPH-M840 Android 4.1版。我正在膨胀的布局是一个简单的FrameLayout,其中包含fragment标记。我正在使用actionbar-compat。

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.customprogrammingsolutions.ShabbosAlarm\/com.cpsolutions.alarmbase.alarm.AlarmMainActivity}: android.view.InflateException: Binary XML file line #30: Error inflating class com.android.internal.widget.ActionBarView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2062)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2087)
    at android.app.ActivityThread.access$600(ActivityThread.java:133)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1198)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4777)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:998)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:765)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class com.android.internal.widget.ActionBarView
    at android.view.LayoutInflater.createView(LayoutInflater.java:619)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3298)
    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3358)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:314)
    at android.app.Activity.setContentView(Activity.java:1901)
    at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:208)
    at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111)
    at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
    at com.cpsolutions.alarmbase.alarm.AlarmMainActivity.onCreate(AlarmMainActivity.java:57)
    at android.app.Activity.performCreate(Activity.java:5042)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2026)
    ... 11 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
    at android.view.LayoutInflater.createView(LayoutInflater.java:593)
    ... 28 more
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.TextView
    at android.view.LayoutInflater.createView(LayoutInflater.java:619)
    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at com.android.internal.widget.ActionBarView.initTitle(ActionBarView.java:834)
    at com.android.internal.widget.ActionBarView.setDisplayOptions(ActionBarView.java:631)
    at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:265)
    ... 31 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
    at android.view.LayoutInflater.createView(LayoutInflater.java:593)
    ... 41 more
Caused by: java.lang.NullPointerException
    at android.server.BluetoothPanProfileHandler.createNewTetheringAddressLocked(BluetoothPanProfileHandler.java:332)
    at android.text.method.SingleLineTransformationMethod.<init>(SingleLineTransformationMethod.java:33)
    at android.text.method.SingleLineTransformationMethod.getInstance(SingleLineTransformationMethod.java:57)
    at android.widget.TextView.applySingleLine(TextView.java:7147)
    at android.widget.TextView.<init>(TextView.java:1208)
    at android.widget.TextView.<init>(TextView.java:606)
    ... 44 more

编辑:以下是onCreate的xml和AlarmMainActivity

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <fragment class="com.cpsolutions.alarmbase.alarm.AlarmListFragment"
          android:id="@+id/alarm_list_frag"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>
</FrameLayout>

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    alarmFrag = (AlarmListFragment) getSupportFragmentManager().findFragmentById(R.id.alarm_list_frag);
    preferenceFrag = (AlarmPreferenceFragment) getSupportFragmentManager().findFragmentById(R.id.preference_list_frag);
    if(preferenceFrag != null) {
        isTwoPane = true;
    }
}

2 个答案:

答案 0 :(得分:0)

您有NullPointerException

  

android.server.BluetoothPanProfileHandler.createNewTetheringAddressLocked(BluetoothPanProfileHandler.java:332)

答案 1 :(得分:0)

使用的布局文件存在问题:

com.cpsolutions.alarmbase.alarm.AlarmMainActivity.java

第57行会有一个setContentView,其参数为R.layout. {insert name here}

转到res/layout/ {在此处插入姓名} .xml并解决问题。

如果您需要帮助,请在此处发布XML文件。


修改

错误是因为它无法使ActionBarView膨胀。请发布课程声明。 (它继承了什么或extends