SimplicityApks / ReminderDatePicker

A Google Keep-like Date and Time Picker for reminders
Apache License 2.0
74 stars 26 forks source link

API 15 Crash - InflateException #32

Closed chrisonline closed 8 years ago

chrisonline commented 8 years ago

I am just now testing my app with API 15 and get a crash after inflate (On API22/23 it works great). On inflating com.simplicity com.simplicityapks.reminderdatepicker.lib.DateSpinner I get the crash.

The Preview in the Android Studio shows also a error in "Rendering Problems" once I set API15: Resource id 0x10100081 is not of type STYLE (instead attr)

Here are the crash details: 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class com.simplicityapks.reminderdatepicker.lib.DateSpinner 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:606) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:798) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:729) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at com.colapps.reminder.ReminderActivity.selectView(ReminderActivity.java:739) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at com.colapps.reminder.ReminderActivity.onCreate(ReminderActivity.java:376) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:4466) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) 10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:123)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4424)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)  10-14 21:18:35.607 16987-16987/com.colapps.reminder E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 

chrisonline commented 8 years ago

Just tested it again and it is working fine with emulators 16 and above. Seems the problem exists on API 15 or the emulator for API15 has some problems.

Don't have a device here with API 15 to test it out.

SimplicityApks commented 8 years ago

Well I can't reproduce this on my API15 emulator... And I am aware that the preview in Android studio cannot be rendered correctly (as is often the case with custom views), just haven't found the time to investigate that as it is not that important to me. Do you use a custom style or different date items for the picker?

chrisonline commented 8 years ago

OK so it seems it is a problem with my API15 emulator...

Here my code:

<com.simplicityapks.reminderdatepicker.lib.DateSpinner
                    android:id="@+id/rdpDate"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="-8dp"
                    android:layout_marginStart="-8dp"
                    android:gravity="left"
                    style="@style/PickerSpinner"
                    android:layout_below="@id/tvLabel_rdpDate"
                    app:flags="weekday_names"/>

XML PickerSpinner:

    <style name="PickerSpinner">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:minHeight">48dp</item>
        <!--spinnerMode >= API Level 11-->
        <item name="android:spinnerMode" ns1:ignore="NewApi">dropdown</item>
    </style>
chrisonline commented 8 years ago

Happy new year!

Today I want to release the new version and only one bug stops this at the moment :-) I think it is a problem in combination with the AppCompatActivity. Did you retry it with an activity who is using AppCompatActivity?

chrisonline commented 8 years ago

Yes I fixed it :-) Seems on Android 4.0 the "onDateSelected()" is fired earlier as on other versions. In this method I use my calendar object and this was null. So the exception was deeper!!

So I will close this issue. Thanks!

SimplicityApks commented 8 years ago

ok cool you fixed it yourself ;), btw just got your update, it's really great!

chrisonline commented 8 years ago

Thanks for the nice feedback and thank you again for a really great library ;-)