某些设备的 NoSuchMethodError

NoSuchMethodError for certain devices

我有一个 Android 应用程序,其中包含一个有 4 个选项的对话框片段,每个选项都指向一个带有点击时附加信息的警告对话框。

此功能适用于我的设备(Galaxy S7 Edge,Android 7.0),但我收到用户的报告,称他们的应用程序在单击选择时崩溃(应打开警报对话框)。

我的诊断表明该错误是由 OnClick 的 NoSuchMethodError 引起的,仅发生在 Android 版本 4.4、5.0、5.1(截至目前)。

有谁知道可能导致此问题的原因是什么?很难排除故障,因为它可以在我的设备上运行。

谢谢!

注意:如果有任何变化,我正在使用 View.OnClickListener。

错误堆栈跟踪示例:

java.lang.NoSuchMethodError: 
  at com.myname.builder.Page.onClick(Page.java:98)
  at android.view.View.performClick(View.java:4459)
  at android.view.View$PerformClick.run(View.java:18443)
  at android.os.Handler.handleCallback(Handler.java:733)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:5128)
  at java.lang.reflect.Method.invokeNative(Native Method:0)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
  at dalvik.system.NativeStart.main(Native Method:0)

这里是有错误的片段:

public class Page extends DialogFragment {

    private View view;
    private ViewHolder holder;
    private String name
    private Object object;

    static class ViewHolder {
        private ImageView a1;
        private TextView a1t;
        private Button close;
        private RelativeLayout a1c;
    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if(view == null)
        {
            view = inflater.inflate(R.layout.kit_page, null);
            holder = new ViewHolder();

            holder.a1c = (RelativeLayout) view.findViewById(...);

            holder.a1 = (ImageView) view.findViewById(...);

            holder.a1t = (TextView) view.findViewById(...);

            holder.close = (Button) view.findViewById(...);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        name = getArguments().getString("name", "N/A");

        object = getByName(name);

        holder.a1t.setText(god.getAb1().getName());
        holder.a1.setImageResource(getDrawableByName(1, god.getString()));


        holder.close.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                dismiss();
            }
        });

        holder.a1c.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v) {
                final AlertDialog dialog;
                LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View mView = inflater.inflate(R.layout.ability_page, null);

        (...)

                final AlertDialog.Builder mBuilder = new AlertDialog.Builder(v.getRootView().getContext());
                mBuilder.setView(mView);
                dialog = mBuilder.create();
                dialog.show();

                Button dismiss = (Button) mView.findViewById(R.id.dismiss);

                dismiss.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
            }
        });

        return view;
    }
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View mView = inflater.inflate(R.layout.ability_page, null); //Replace null with the Container 

        (...)
//or
                final AlertDialog.Builder mBuilder = new AlertDialog.Builder(v.getRootView().getContext()); // Simply pass the Page.this here
                mBuilder.setView(mView);
                dialog = mBuilder.create();
                dialog.show();