prolificinteractive / material-calendarview

A Material design back port of Android's CalendarView
https://prolificinteractive.github.io/material-calendarview/
MIT License
5.92k stars 1.32k forks source link

Inflation exception when using Java 8 dependency #944

Open mpowloka opened 5 years ago

mpowloka commented 5 years ago

UPDATE: Some time after posting this issue I found it is because of Java 8 dependency in the project. Removing it removed the issue. Although this is still a problem to look into.

compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

I make a simple test application with MaterialCalendarView in fragment and I get following exception. It leads nowhere to my code. The calendar is placed in fragment and I use AndroidX if that is relevant.

I use the latest library version. Ask me for any further info as necessary.

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.listonic.calendars, PID: 10150 android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.prolificinteractive.materialcalendarview.MaterialCalendarView Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.prolificinteractive.materialcalendarview.MaterialCalendarView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.listonic.calendars.ProlificInteractiveCalendarFragment.onCreateView(ProlificInteractiveCalendarFragment.kt:19) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2539) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875) at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2084) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1858) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1814) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1715) at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManagerImpl.java:143) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.NoSuchFieldError: No static field header of type I in class Lcom/prolificinteractive/materialcalendarview/R$id; or its superclasses (declaration of 'com.prolificinteractive.materialcalendarview.R$id' appears in /data/app/com.listonic.calendars-pw6ERmJWegl42I_gSgmS3w==/base.apk!classes2.dex) at com.prolificinteractive.materialcalendarview.MaterialCalendarView.<init>(MaterialCalendarView.java:266) at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)  at android.view.LayoutInflater.createView(LayoutInflater.java:647)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at com.listonic.calendars.ProlificInteractiveCalendarFragment.onCreateView(ProlificInteractiveCalendarFragment.kt:19)  at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2539)  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875)  at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2084)  at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1858)  at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1814)  at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1715)  at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManagerImpl.java:143)  at android.os.Handler.handleCallback(Handler.java:873)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

My layout:

` <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

<com.prolificinteractive.materialcalendarview.MaterialCalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout> `

VadherKhushal commented 4 years ago

We are also facing same issue. Any solution for this.

Caused by: android.view.InflateException: Binary XML file line #78: Error inflating class com.prolificinteractive.materialcalendarview.MaterialCalendarView

Caused by: java.lang.NoSuchFieldError: No static field header of type I in class Lcom/prolificinteractive/materialcalendarview/R$id; or its superclasses (declaration of 'com.prolificinteractive.materialcalendarview.R$id' appears in 7DLYaWTj_TIcgfYZ7PTE1Q==/base.apk!classes2.dex) at com.prolificinteractive.materialcalendarview.MaterialCalendarView.(MaterialCalendarView.java:266)

vajjasivateja commented 4 years ago

seems this solution you mentioned not working, are you using 2.0.1 which is latest?