ImaginativeShohag / Why-Not-Image-Carousel

Why Not use Image Carousel if you have lots of images to show!
https://imaginativeshohag.github.io/Why-Not-Image-Carousel/
Apache License 2.0
479 stars 67 forks source link

App crashes after importing ImageCarousel view element in XML #107

Open BuktopMKD opened 1 year ago

BuktopMKD commented 1 year ago

Added all dependancyes in build.gradle file. Was following your documentation and added ImageCarousel view element in my layout. After that there is a crash with this log:

FATAL EXCEPTION: main
Process: com.example, PID: 26389
android.view.InflateException: Binary XML file line #11 in com.example:layout/fragment_carousel: Binary XML file line #11 in com.example:layout/fragment_carousel: Error inflating class org.imaginativeworld.whynotimagecarousel.ImageCarousel
Caused by: android.view.InflateException: Binary XML file line #11 in com.example:layout/fragment_carousel: Error inflating class org.imaginativeworld.whynotimagecarousel.ImageCarousel
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:858)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
    at com.example.databinding.FragmentCarouselBinding.inflate(FragmentCarouselBinding.java:45)
    at com.example.ui.home.carousel.CarouselFragment.onCreateView(CarouselFragment.kt:23)
    at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
    at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1751)
    at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
    at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:341)
    at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:276)
    at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:67)
    at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7867)
    at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:893)
    at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8902)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8860)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8848)
    at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1645)
    at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
    at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1395)
    at androidx.recyclerview.widget.LinearLayoutManager.scrollHorizontallyBy(LinearLayoutManager.java:1124)
    at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1969)
    at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5476)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
    at android.view.Choreographer.doCallbacks(Choreographer.java:899)
    at android.view.Choreographer.doFrame(Choreographer.java:827)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
ImaginativeShohag commented 5 months ago

Please provide a minimal example project to try the issue.