这篇文章上次修改于 1908 天前,可能其部分内容已经发生变化,如有疑问可询问作者。 >安卓开发使用androidx 的circleimage 报错: Caused by: java.lang.NoSuchMethodException: androidx.swiperefreshlayout.widget.CircleImageView. 原因是这个类是私有的,只好使用 ,de.hdodenhof:circleimageview 1.加入依赖 ```bash api 'de.hdodenhof:circleimageview:2.2.0' ``` 2.使用 ```xml ``` 完整报错 ```bash E/AndroidRuntime: FATAL EXCEPTION: main Process: com.greenhtml.demo, PID: 5645 android.view.InflateException: Binary XML file line #6 in com.greenhtml.demo:layout/layout_listitem: Binary XML file line #6 in com.greenhtml.demo:layout/layout_listitem: Error inflating class androidx.swiperefreshlayout.widget.CircleImageView Caused by: android.view.InflateException: Binary XML file line #6 in com.greenhtml.demo:layout/layout_listitem: Error inflating class androidx.swiperefreshlayout.widget.CircleImageView Caused by: java.lang.NoSuchMethodException: androidx.swiperefreshlayout.widget.CircleImageView. [class android.content.Context, interface android.util.AttributeSet] at java.lang.Class.getConstructor0(Class.java:2332) at java.lang.Class.getConstructor(Class.java:1728) at android.view.LayoutInflater.createView(LayoutInflater.java:824) 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.greenhtml.demo.adapters.RecyclerAdapter.onCreateViewHolder(RecyclerAdapter.kt:50) at com.greenhtml.demo.adapters.RecyclerAdapter.onCreateViewHolder(RecyclerAdapter.kt:20) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6992) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6161) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6044) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6040) 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:4063) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3780) at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4333) at android.view.View.layout(View.java:21892) at android.view.ViewGroup.layout(ViewGroup.java:6260) at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1193) at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:880) at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:899) at android.view.View.layout(View.java:21892) 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:21892) at android.view.ViewGroup.layout(ViewGroup.java:6260) at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:446) at android.view.View.layout(View.java:21892) 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:21892) 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:21892) 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:773) at android.view.View.layout(View.java:21892) at android.view.ViewGroup.layout(ViewGroup.java:6260) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3078) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2588) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7595) 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:7319) 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:934) ```
没有评论