先来看下报的异常,仅仅贴了主要部分:
Process: com.dudu.duduhelper, PID: 13694
android.view.InflateException: Binary XML file line #46: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at com.dudu.duduhelper.Activity.BigBandActivity.ShopProductAddActivity.showAlertDailog(ShopProductAddActivity.java:151)
at com.dudu.duduhelper.Activity.BigBandActivity.ShopProductAddActivity.SubmitProduct(ShopProductAddActivity.java:347)
at com.dudu.duduhelper.Activity.BigBandActivity.ShopProductAddActivity.access$1000(ShopProductAddActivity.java:67)
at com.dudu.duduhelper.Activity.BigBandActivity.ShopProductAddActivity$11.onClick(ShopProductAddActivity.java:510)
这个异常是加载xml文件异常, 也定位到具体的位置:
android.view.InflateException: Binary XML file line #46:
还有代码中首次出现的位置:
at com.dudu.duduhelper.Activity.BigBandActivity.ShopProductAddActivity.showAlertDailog(ShopProductAddActivity.java:151)
解析过来就是说在你的源码的151行位置加载xml文件报错了,对应的xml中的46行有错误。
对应的xml文件:
<span style="font-family:Arial, Helvetica, sans-serif;"></span><pre name="code" class="html"> android:src="@color/list_divide"/>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="50dp">
<Button
android:id="@+id/confirm"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@null"
android:text="确定"
android:textSize="18dp"
/>
<view
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:src="@color/list_divide"/
细心的朋友已经发现错误了,46行是<view 这里,我的v是小写,但是编辑的时候不报错,只有程序编译才报错,所以不容易发现。
以后类似的问题就可以分2步去解析:先看错误日志定位源码位置,根据源码位置找错误的xml位置。