This is my dependency in build.gradle, after syncing the output shows everything is fine
dependencies{
implementation("com.github.bumptech.glide:glide:4.16.0")
implementation("io.github.panpf.zoomimage:zoomimage-view-glide:1.0.2")
implementation("io.github.panpf.zoomimage:zoomimage-compose-glide:1.0.2")
}
Line causing the error in the XML
<com.github.panpf.zoomimage.GlideZoomImageView
android:id="@+id/page_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/colorful"/>
Log cat output
FATAL EXCEPTION: main
Process: com.example.gallery, PID: 9594
android.view.InflateException: Binary XML file line #10 in com.example.gallery:layout/item_page: Binary XML file line #10 in com.example.gallery:layout/item_page: Error inflating class com.github.panpf.zoomimage.GlideZoomImageView
Caused by: android.view.InflateException: Binary XML file line #10 in com.example.gallery:layout/item_page: Error inflating class com.github.panpf.zoomimage.GlideZoomImageView
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:854)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.example.gallery.component.ViewPagerAdapter.onCreateViewHolder(ViewPagerAdapter.java:37)
at com.example.gallery.component.ViewPagerAdapter.onCreateViewHolder(ViewPagerAdapter.java:24)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:527)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:779)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3080)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/github/panpf/zoomimage/util/AndroidLogPipeline;
at com.github.panpf.zoomimage.ZoomImageView.<init>(ZoomImageView.kt:86)
at com.github.panpf.zoomimage.GlideZoomImageView.<init>(GlideZoomImageView.kt:48)
at com.github.panpf.zoomimage.GlideZoomImageView.<init>(GlideZoomImageView.kt:44)
at com.github.panpf.zoomimage.GlideZoomImageView.<init>(Unknown Source:11)
... 70 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.github.panpf.zoomimage.util.AndroidLogPipeline" on path: DexPathList[[zip file "/data/app/com.example.gallery-MgsZxVno6qLaOaRNpE91qQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.gallery-MgsZxVno6qLaOaRNpE91qQ==/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 74 more
In Android Studio it doesn't show any highlighting for the XML error but the error only occurs once I try to inflate the layout.
I tried Invalidate caches and restart but still didn't work. I also tried to use the class in my java code like this and still get the same error
@NonNull
@Override
public ViewPagerAdapter.ViewPagerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_page, parent, false);
return new ViewPagerViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewPagerAdapter.ViewPagerViewHolder holder, int position) {
String image = images.get(position);
// Just trying to run this line cause the error
GlideZoomImageView glideZoomImageView = new GlideZoomImageView(holder.imageView.getContext());
Glide.with(holder.itemView).load(image).into(holder.imageView);
}