升级应用程序后膨胀 class android.widget.ImageButton 时出错

Error inflating class android.widget.ImageButton after upgrading app

我正在尝试升级以前使用过 ActionBarSherlock 的旧应用程序。我想我已经用更新的东西替换了所有使用它的东西。目前我在标题上遇到了错误,这很奇怪而且肯定很难修复。我已经查找了它的修复程序并应用了其中的每一个,但我仍然收到错误。我尝试使用 AppCompatImageButton,但当我这样做时,错误现在显示为 Error inflating class android.widget.AppCompatImageButton。错误日志如下。

FATAL EXCEPTION: main
    Process: com.csipsimple, PID: 22863
    android.view.InflateException: Binary XML file line #113: Binary XML file line #4: Error inflating class com.csipsimple.widgets.Dialpad
    Caused by: android.view.InflateException: Binary XML file line #4: Error inflating class com.csipsimple.widgets.Dialpad
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(Unknown Source:194)
        at android.view.LayoutInflater.createViewFromTag(Unknown Source:197)
        at android.view.LayoutInflater.createViewFromTag(Unknown Source:6)
        at android.view.LayoutInflater.rInflate(Unknown Source:101)
        at android.view.LayoutInflater.parseInclude(Unknown Source:284)
        at android.view.LayoutInflater.rInflate(Unknown Source:79)
        at android.view.LayoutInflater.rInflateChildren(Unknown Source:9)
        at android.view.LayoutInflater.inflate(Unknown Source:264)
        at android.view.LayoutInflater.inflate(Unknown Source:20)
        at com.csipsimple.ui.dialpad.DialerFragment.onCreateView(DialerFragment.java:211)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
        at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
        at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1244)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1092)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1622)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewGroup.measureChildWithMargins(Unknown Source:42)
        at android.widget.FrameLayout.onMeasure(Unknown Source:65)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewGroup.measureChildWithMargins(Unknown Source:42)
        at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(Unknown Source:340)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewGroup.measureChildWithMargins(Unknown Source:42)
        at android.widget.FrameLayout.onMeasure(Unknown Source:65)
        at com.android.internal.policy.DecorView.onMeasure(Unknown Source:344)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewRootImpl.performMeasure(Unknown Source:15)
        at android.view.ViewRootImpl.measureHierarchy(Unknown Source:78)
        at android.view.ViewRootImpl.performTraversals(Unknown Source:446)
        at android.view.ViewRootImpl.doTraversal(Unknown Source:32)
        at android.view.ViewRootImpl$TraversalRunnable.run(Unknown Source:2)
        at android.view.Choreographer$CallbackRecord.run(Unknown Source:20)
        at android.view.Choreographer.doCallbacks(Unknown Source:106)
        at android.view.Choreographer.doFrame(Unknown Source:212)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Unknown Source:9)
        at android.os.Handler.handleCallback(Unknown Source:2)
        at android.os.Handler.dispatchMessage(Unknown Source:4)
        at android.os.Looper.loop(Unknown Source:152)
        at android.app.ActivityThread.main(Unknown Source:65)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
2019-07-22 23:57:16.019 22863-22863/com.csipsimple E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(Unknown Source:338)
     Caused by: android.view.InflateException: Binary XML file line #32: Binary XML file line #32: Error inflating class android.widget.ImageButton
     Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.widget.ImageButton
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(Unknown Source:194)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(Unknown Source:8)
        at android.view.LayoutInflater.onCreateView(Unknown Source:0)
        at android.view.LayoutInflater.createViewFromTag(Unknown Source:155)
        at android.view.LayoutInflater.createViewFromTag(Unknown Source:6)
        at android.view.LayoutInflater.rInflate(Unknown Source:101)
        at android.view.LayoutInflater.rInflateChildren(Unknown Source:9)
        at android.view.LayoutInflater.rInflate(Unknown Source:112)
        at android.view.LayoutInflater.rInflateChildren(Unknown Source:9)
        at android.view.LayoutInflater.inflate(Unknown Source:264)
        at android.view.LayoutInflater.inflate(Unknown Source:20)
        at com.csipsimple.widgets.Dialpad.initLayout(Dialpad.java:112)
        at com.csipsimple.widgets.Dialpad.<init>(Dialpad.java:107)
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(Unknown Source:194)
        at android.view.LayoutInflater.createViewFromTag(Unknown Source:197)
        at android.view.LayoutInflater.createViewFromTag(Unknown Source:6)
        at android.view.LayoutInflater.rInflate(Unknown Source:101)
        at android.view.LayoutInflater.parseInclude(Unknown Source:284)
        at android.view.LayoutInflater.rInflate(Unknown Source:79)
        at android.view.LayoutInflater.rInflateChildren(Unknown Source:9)
        at android.view.LayoutInflater.inflate(Unknown Source:264)
        at android.view.LayoutInflater.inflate(Unknown Source:20)
        at com.csipsimple.ui.dialpad.DialerFragment.onCreateView(DialerFragment.java:211)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
        at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
        at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1244)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1092)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1622)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewGroup.measureChildWithMargins(Unknown Source:42)
        at android.widget.FrameLayout.onMeasure(Unknown Source:65)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewGroup.measureChildWithMargins(Unknown Source:42)
        at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(Unknown Source:340)
        at android.view.View.measure(Unknown Source:250)
        at android.view.ViewGroup.measureChildWithMargins(Unknown Source:42)
        at android.widget.FrameLayout.onMeasure(Unknown Source:65)
        at com.android.internal.policy.DecorView.onMeasure(Unknown Source:344)
2019-07-22 23:57:16.021 22863-22863/com.csipsimple E/AndroidRuntime:     at android.view.View.measure(Unknown Source:250)
        at android.view.ViewRootImpl.performMeasure(Unknown Source:15)
        at android.view.ViewRootImpl.measureHierarchy(Unknown Source:78)
        at android.view.ViewRootImpl.performTraversals(Unknown Source:446)
        at android.view.ViewRootImpl.doTraversal(Unknown Source:32)
        at android.view.ViewRootImpl$TraversalRunnable.run(Unknown Source:2)
        at android.view.Choreographer$CallbackRecord.run(Unknown Source:20)
        at android.view.Choreographer.doCallbacks(Unknown Source:106)
        at android.view.Choreographer.doFrame(Unknown Source:212)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Unknown Source:9)
        at android.os.Handler.handleCallback(Unknown Source:2)
        at android.os.Handler.dispatchMessage(Unknown Source:4)
        at android.os.Looper.loop(Unknown Source:152)
        at android.app.ActivityThread.main(Unknown Source:65)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
        at com.android.internal.os.ZygoteInit.main(Unknown Source:338)
     Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f030002 a=6}
        at android.content.res.TypedArray.getDrawableForDensity(Unknown Source:61)
        at android.content.res.TypedArray.getDrawable(Unknown Source:1)
        at android.view.View.<init>(Unknown Source:132)
        at android.widget.ImageView.<init>(Unknown Source:7)
        at android.widget.ImageButton.<init>(Unknown Source:0)
        at android.widget.ImageButton.<init>(Unknown Source:1)
        at android.widget.ImageButton.<init>(Unknown Source:3)
            ... 68 more

DialogFragment.java:211 是

final View v = inflater.inflate(R.layout.dialer_digit, container, false);

dialer_digit.xml 是

<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2010 Regis Montoya (aka r3gis - www.r3gis.fr) 
    Copyright (C) 2008 The Android Open Source Project

    This file is part of CSipSimple.
    CSipSimple is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    If you own a pjsip commercial license you can also redistribute it
    and/or modify it under the terms of the GNU Lesser General Public License
    as an android library.

    CSipSimple is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with CSipSimple.  If not, see <http://www.gnu.org/licenses/>.
-->

<com.csipsimple.ui.dialpad.DialerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/top_digit_dialer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="false"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/topField"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/dialpad_background"
        android:orientation="horizontal">

        <com.csipsimple.ui.dialpad.DigitsEditText
            android:id="@+id/digitsText"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_toStartOf="@+id/accountChooserButton"
            android:layout_toLeftOf="@+id/accountChooserButton"
            android:background="@android:color/transparent"
            android:contentDescription="@string/description_digits_edittext"
            android:gravity="center"
            android:imeActionLabel="@string/call"
            android:imeOptions="actionGo"
            android:nextFocusRight="@+id/accountChooserButton"
            android:textAppearance="@style/DialtactsDigitsTextAppearance"
            android:textColor="@android:color/white" />

        <TextView
            android:id="@+id/rewriteTextInfo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"
            android:layout_toLeftOf="@+id/accountChooserButton"
            android:layout_toStartOf="@+id/accountChooserButton"
            android:gravity="center"
            android:textColor="#88FFFFFF"
            android:textSize="12sp"
            android:textStyle="italic"
            android:visibility="gone" />

        <com.csipsimple.widgets.AccountChooserButton
            android:id="@+id/accountChooserButton"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true" />

        <RelativeLayout
            android:id="@+id/lytCallFrontDesk"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#40aaaaaa"
            android:gravity="center_vertical">

            <ImageView
                android:id="@+id/imgDialerDigitCall"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_margin="8dp"
                android:adjustViewBounds="true"
                android:contentDescription="telephone_logo"
                android:cropToPadding="false"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:scaleType="fitCenter"
                android:src="@drawable/csip_guest_services" />

        </RelativeLayout>

    </RelativeLayout>
    <!-- Autocomplete -->

    <ListView
        android:id="@+id/autoCompleteList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="@integer/dialpad_layout_weight_autocomplete_list"
        android:visibility="gone" />

    <!-- Keypad section -->

    <include layout="@layout/dialpad_compose" />

</com.csipsimple.ui.dialpad.DialerLayout>

DialerLayout 是 LinearLayout.

拨号盘是

/*
 * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr)
 * This file is part of CSipSimple.
 *
 *  CSipSimple is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  If you own a pjsip commercial license you can also redistribute it
 *  and/or modify it under the terms of the GNU Lesser General Public License
 *  as an android library.
 *
 *  CSipSimple is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CSipSimple.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.csipsimple.widgets;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.ToneGenerator;
import android.support.v7.widget.AppCompatImageButton;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;

import com.csipsimple.R;
import com.csipsimple.utils.Theme;

import java.util.HashMap;
import java.util.Map;

public class Dialpad extends FrameLayout implements View.OnClickListener {

    private OnDialKeyListener onDialKeyListener;

    // Here we need a map to quickly find if the clicked button id is in the map keys
    @SuppressLint("UseSparseArrays")
    private static final Map<Integer, int[]> DIGITS_BTNS = new HashMap<>();

    static {
        DIGITS_BTNS.put(R.id.button0, new int[] {ToneGenerator.TONE_DTMF_0, KeyEvent.KEYCODE_0});
        DIGITS_BTNS.put(R.id.button1, new int[] {ToneGenerator.TONE_DTMF_1, KeyEvent.KEYCODE_1});
        DIGITS_BTNS.put(R.id.button2, new int[] {ToneGenerator.TONE_DTMF_2, KeyEvent.KEYCODE_2});
        DIGITS_BTNS.put(R.id.button3, new int[] {ToneGenerator.TONE_DTMF_3, KeyEvent.KEYCODE_3});
        DIGITS_BTNS.put(R.id.button4, new int[] {ToneGenerator.TONE_DTMF_4, KeyEvent.KEYCODE_4});
        DIGITS_BTNS.put(R.id.button5, new int[] {ToneGenerator.TONE_DTMF_5, KeyEvent.KEYCODE_5});
        DIGITS_BTNS.put(R.id.button6, new int[] {ToneGenerator.TONE_DTMF_6, KeyEvent.KEYCODE_6});
        DIGITS_BTNS.put(R.id.button7, new int[] {ToneGenerator.TONE_DTMF_7, KeyEvent.KEYCODE_7});
        DIGITS_BTNS.put(R.id.button8, new int[] {ToneGenerator.TONE_DTMF_8, KeyEvent.KEYCODE_8});
        DIGITS_BTNS.put(R.id.button9, new int[] {ToneGenerator.TONE_DTMF_9, KeyEvent.KEYCODE_9});
        DIGITS_BTNS.put(R.id.buttonpound, new int[] {ToneGenerator.TONE_DTMF_P, KeyEvent.KEYCODE_POUND});
        DIGITS_BTNS.put(R.id.buttonstar, new int[] {ToneGenerator.TONE_DTMF_S, KeyEvent.KEYCODE_STAR});
    }

    private static final SparseArray<String> DIGITS_NAMES = new SparseArray<>();

    private static final String THIS_FILE = null;
    static {
        DIGITS_NAMES.put(R.id.button0, "0");
        DIGITS_NAMES.put(R.id.button1, "1");
        DIGITS_NAMES.put(R.id.button2, "2");
        DIGITS_NAMES.put(R.id.button3, "3");
        DIGITS_NAMES.put(R.id.button4, "4");
        DIGITS_NAMES.put(R.id.button5, "5");
        DIGITS_NAMES.put(R.id.button6, "6");
        DIGITS_NAMES.put(R.id.button7, "7");
        DIGITS_NAMES.put(R.id.button8, "8");
        DIGITS_NAMES.put(R.id.button9, "9");
        DIGITS_NAMES.put(R.id.buttonpound, "pound");
        DIGITS_NAMES.put(R.id.buttonstar, "star");
    }

    /**
     * Interface definition for a callback to be invoked when a tab is triggered
     * by moving it beyond a target zone.
     */
    public interface OnDialKeyListener {

        /**
         * Called when the user make an action
         * 
         * @param keyCode keyCode pressed
         * @param dialTone corresponding dialtone
         */
        void onTrigger(int keyCode, int dialTone);
    }

    public Dialpad(Context context) {
        super(context);
        initLayout(context);
    }

    public Dialpad(Context context, AttributeSet attrs) {
        super(context, attrs);
        initLayout(context);
    }

    private void initLayout(Context context) {
        LayoutInflater inflater = LayoutInflater.from(context);
        inflater.inflate(R.layout.dialpad, this, true);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        for(int buttonId : DIGITS_BTNS.keySet()) {
            ImageButton button = findViewById(buttonId);
            if(button != null) {
                button.setOnClickListener(this);
            }
        }

    }


    /**
     * Registers a callback to be invoked when the user triggers an event.
     * 
     * @param listener
     *            the OnTriggerListener to attach to this view
     */
    public void setOnDialKeyListener(OnDialKeyListener listener) {
        onDialKeyListener = listener;
    }

    private void dispatchDialKeyEvent(int buttonId) {
        if (onDialKeyListener != null && DIGITS_BTNS.containsKey(buttonId)) {
            int[] datas = DIGITS_BTNS.get(buttonId);
            onDialKeyListener.onTrigger(datas[1], datas[0]);
        }
    }

    @Override
    public void onClick(View v) {
        dispatchDialKeyEvent(v.getId());

    }
    /*
    boolean mForceWidth = false;
    public void setForceWidth(boolean forceWidth) {
        mForceWidth = forceWidth;
    }

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        if(mForceWidth) {
            setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), getMeasuredHeight());
        }
    };
    */


    public void applyTheme(Theme t) {

        Log.d(THIS_FILE, "Theming in progress");
        for(int buttonId : DIGITS_BTNS.keySet()) {

            ImageButton b = findViewById(buttonId);
            // We need to use state list as reused
            t.applyBackgroundStateListDrawable(b, "btn_dial");

            // Src of button
            Drawable src = t.getDrawableResource("dial_num_"+DIGITS_NAMES.get(buttonId));
            if(src != null) {
                b.setImageDrawable(src);
            }

            // Padding of button
            t.applyLayoutMargin(b, "dialpad_btn_margin");
        }

    }

}

下面是dialpad.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2010 Regis Montoya (aka r3gis - www.r3gis.fr) 

    This file is part of CSipSimple.
    CSipSimple is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    If you own a pjsip commercial license you can also redistribute it
    and/or modify it under the terms of the GNU Lesser General Public License
    as an android library.

    CSipSimple is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with CSipSimple.  If not, see <http://www.gnu.org/licenses/>.
-->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/button1"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_one"
            app:srcCompat="@drawable/dial_num_1" />

        <ImageButton
            android:id="@+id/button2"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_two"
            app:srcCompat="@drawable/dial_num_2" />

        <ImageButton
            android:id="@+id/button3"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_three"
            app:srcCompat="@drawable/dial_num_3" />
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/button4"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_four"
            app:srcCompat="@drawable/dial_num_4" />

        <ImageButton
            android:id="@+id/button5"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_five"
            app:srcCompat="@drawable/dial_num_5" />

        <ImageButton
            android:id="@+id/button6"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_six"
            app:srcCompat="@drawable/dial_num_6" />
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/button7"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_seven"
            app:srcCompat="@drawable/dial_num_7" />

        <ImageButton
            android:id="@+id/button8"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_eight"
            app:srcCompat="@drawable/dial_num_8" />

        <ImageButton
            android:id="@+id/button9"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_nine"
            app:srcCompat="@drawable/dial_num_9" />
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/buttonstar"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_star"
            app:srcCompat="@drawable/dial_num_star" />

        <ImageButton
            android:id="@+id/button0"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_zero"
            app:srcCompat="@drawable/dial_num_0" />

        <ImageButton
            android:id="@+id/buttonpound"
            style="@style/DialtactsDialpadButtonStyle"
            android:contentDescription="@string/description_image_button_pound"
            app:srcCompat="@drawable/dial_num_pound" />
    </TableRow>

</TableLayout>

我目前升级的应用程序是由 Regis Montoya 开发的,我确信它运行良好。

我很确定你的风格问题(styles.xml)。

   <style name="DialtactsDialpadButtonStyle">
        <item name="android:layout_width">0dip</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_weight">1</item>
        <item name="android:background">?attr/actionBarItemBackground</item>
    </style>

尝试删除或更改行:

<item name="android:background">?attr/actionBarItemBackground</item>

似乎在扩充布局时找不到 ?attr/actionBarItemBackground

更新:

为什么会发生这种情况以及为什么它在没有修复来自 https://github.com/r3gis3r/CSipSimple/issues/69 的现成 apk 的情况下工作:

在您的构建中,在为 ImageButton 设置的主题中找不到 ?attr/actionBarItemBackground。 这个主题是 <style name="DarkTheme.Dialog" parent="Theme.Sherlock.Dialog">

Theme.Sherlock.Dialog 是在 JakeWharton 的 ActionBarSherlock 中定义的。但是它被提交 601bde214b56b8fad0b4fc5aaed5af0b531b6135

删除了

这就是为什么旧 apk 工作正常而新版本(使用“最新”ActionBarSherlock)崩溃的原因。