Exception : android.view.InflateException: Binary

2019-03-03 15:44发布

问题:

I am working on android application where I am using simonvt datepicker library because of backward compatible but I see in my developer console crash report there are 3 reports for this same error but this I tried in my device that is working so this is really weird.

Please support for this why it so strange and getting exception sometime.

OnDateSetListener date = new OnDateSetListener() {

    private void updateLabel() {

        String myFormat = "EEE, dd MMM"; // In which you need put here
        String myDbFormat = "dd/MM/yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
        SimpleDateFormat DBsdf = new SimpleDateFormat(myDbFormat, Locale.US);
        Departure_date = sdf.format(myCalendar.getTime());
        Departure_date_url = DBsdf.format(myCalendar.getTime());

        Log.i("Departure_date", Departure_date);
        date_btn.setText(sdf.format(myCalendar.getTime()));
    }

    @Override
    public void onDateSet(net.simonvt.datepicker.DatePicker view, int year,
            int monthOfYear, int dayOfMonth) {
        myCalendar.set(Calendar.YEAR, year);
        myCalendar.set(Calendar.MONTH, monthOfYear);
        myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
        updateLabel();
    }
};

Line no : 703

final net.simonvt.datepicker.DatePickerDialog dpd = new net.simonvt.datepicker.DatePickerDialog(
                            getActivity(), date, myCalendar.get(Calendar.YEAR),
                            myCalendar.get(Calendar.MONTH), myCalendar
                                    .get(Calendar.DAY_OF_MONTH));

Logcat :

android.view.InflateException: Binary XML file line #20: Error inflating class net.simonvt.datepicker.DatePicker
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at net.simonvt.datepicker.DatePickerDialog.<init>(DatePickerDialog.java:106)
at net.simonvt.datepicker.DatePickerDialog.<init>(DatePickerDialog.java:77)
at in.mypackage$15.onClick(RailTicket_Book.java:703)
at android.widget.AutoCompleteTextView$PassThroughClickListener.onClick(AutoCompleteTextView.java:1260)
at android.view.View.performClick(View.java:4471)
at android.view.View$PerformClick.run(View.java:18797)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
... 19 more
Caused by: java.lang.IllegalArgumentException: Bad pattern character 'E' in EE,dd MMM yyyy
at libcore.icu.ICU.getDateFormatOrder(ICU.java:165)
at android.text.format.DateFormat.getDateFormatOrder(DateFormat.java:388)
at net.simonvt.datepicker.DatePicker.reorderSpinners(DatePicker.java:515)
at net.simonvt.datepicker.DatePicker.<init>(DatePicker.java:284)
at net.simonvt.datepicker.DatePicker.<init>(DatePicker.java:149)
... 22 more

Thanks in advance

回答1:

I noticed that there is some bug in simonvt datepicker that was the reason for the exception. I moved again to DatePicker that android provides that worked really awesome without any more exception.