wdullaer / MaterialDateTimePicker

Pick a date or time on Android in style
Apache License 2.0
4.67k stars 948 forks source link

Layout inflate Error on 4.4.2 (api 19) #416

Open jirevwe opened 7 years ago

jirevwe commented 7 years ago

Hi,

I tried testing the datetime picker on a device running an old OS, though no errors occur when I run it on newer devices.

Device: Tecno J7 OS: 4.4.2 (api 19)

I'm creating a dialog like this

Calendar now = Calendar.getInstance();
DatePickerDialog dpd = DatePickerDialog.newInstance(this,
    now.get(Calendar.YEAR),
    now.get(Calendar.MONTH),
    now.get(Calendar.DAY_OF_MONTH)
);
dpd.setMinDate(now);
dpd.setTitle(date);
dpd.setCancelable(true);
dpd.setVersion(DatePickerDialog.Version.VERSION_2);
dpd.show(getActivity().getFragmentManager(), "Date Picker Dialog");

And I got this error...

Fatal Exception: android.view.InflateException: Binary XML file line #26: Error inflating class Button
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
       at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
       at com.wdullaer.materialdatetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:318)
       at android.app.Fragment.performCreateView(Fragment.java:1700)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
       at android.app.BackStackRecord.run(BackStackRecord.java:698)
       at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
       at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
       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:5323)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.IndexOutOfBoundsException
       at android.content.res.StringBlock.nativeGetString(StringBlock.java)
       at android.content.res.StringBlock.get(StringBlock.java:82)
       at android.content.res.AssetManager.getPooledString(AssetManager.java:288)
       at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:727)
       at android.content.res.TypedArray.getString(TypedArray.java:125)
       at android.widget.TextView.<init>(TextView.java:1002)
       at android.widget.Button.<init>(Button.java:107)
       at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:71)
       at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:67)
       at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:109)
       at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
       at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
       at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
       at com.wdullaer.materialdatetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:318)
       at android.app.Fragment.performCreateView(Fragment.java:1700)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
       at android.app.BackStackRecord.run(BackStackRecord.java:698)
       at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
       at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
       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:5323)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
       at dalvik.system.NativeStart.main(NativeStart.java)
wdullaer commented 7 years ago

Does version 1 work on the old device? I get these issues every now and then, but I can never reproduce them on the emulator.

jirevwe commented 7 years ago

Still crashes but with a different error...

I can't seem to figure out why some widget are not inflated though... It works on android 4.4.4

Fatal Exception: android.view.InflateException: Binary XML file line #37: Error inflating class TextView
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
       at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
       at com.wdullaer.materialdatetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:318)
       at android.app.Fragment.performCreateView(Fragment.java:1700)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
       at android.app.BackStackRecord.run(BackStackRecord.java:698)
       at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
       at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
       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:5323)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.ArrayIndexOutOfBoundsException: length=23; index=5877
       at android.content.res.StringBlock.get(StringBlock.java:65)
       at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
       at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:721)
       at android.content.res.TypedArray.getString(TypedArray.java:125)
       at android.widget.TextView.<init>(TextView.java:1002)
       at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:75)
       at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:71)
       at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
       at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
       at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
       at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
       at com.wdullaer.materialdatetimepicker.date.DatePickerDialog.onCreateView(DatePickerDialog.java:318)
       at android.app.Fragment.performCreateView(Fragment.java:1700)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
       at android.app.BackStackRecord.run(BackStackRecord.java:698)
       at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
       at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
       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:5323)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
       at dalvik.system.NativeStart.main(NativeStart.java)
wdullaer commented 7 years ago

This is exactly the same stacktrace that the other issue had. As I said I haven't been able to reproduce this on the emulator. I'll try again, but if it still fails are you up for helping me debug this? I'll let you what exactly I'd like you to test later this week.

jirevwe commented 7 years ago

Yeah sure...

wdullaer commented 7 years ago

I think I have the stacktrace on the v2 layout traced down. The one on the TextView I'm the v1 layout still eludes me.

jirevwe commented 7 years ago

Any luck on this issue?

wdullaer commented 7 years ago

I haven't had any time over the weekend to look at this. It's still the first thing on the list

wdullaer commented 7 years ago

I've pushed the potential fix for the v2 layout into the branch issue-416-inflate-error I really can't spot anything wrong with the v1 error (at least not at the place indicated by the stacktrace) I tried on a few different emulator images to reproduce this, but I've had no luck.

Can you check out this branch and try the sample app on the device that has the issue.

Secondly, could you attach the debugger to the sample app for this device and try to figure out what the actual error is (the inflate exception generally masks an underlying other exception)? You could do this by enabling "break on exception" in android studio. If I know what the underlying exception is, I'll have a shot at properly debugging this.