I created an app which uses this hdodenhof CircleImageview
library.
My app works fine on Android 7 and 7.1 but it is crashing in lower versions such as marshmallow/Android 6. How can I solve this problem? I have read his GitHub posts but it did not solve my problem as people has asked to remove attributes from the .xml, but I didn't use these attributes.
Here's my simple implementation of the CircleImageView:
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/civ_requests"
android:layout_width="80sp"
android:layout_height="80sp"
android:layout_margin="10sp"
android:src="@drawable/profilesvg" />
And heres the error:
FATAL EXCEPTION: main
Process: com.milind.locatemymate, PID: 4288
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class de.hdodenhof.circleimageview.CircleImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.milind.locatemymate.Fragment.Requests$1.onCreateViewHolder(Requests.java:152)
at com.milind.locatemymate.Fragment.Requests$1.onCreateViewHolder(Requests.java:103)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1632)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
Same error in friends fragment, heres its updated xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:src="@drawable/profilesvg"
android:id="@+id/civ_friend"
android:layout_width="80dp"
android:layout_height="80dp" />
<LinearLayout
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textStyle="bold"
android:textColor="@color/LightBlack"
android:id="@+id/tv_friendName"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/LightBlack"
android:layout_marginTop="5dp"
android:id="@+id/tv_friendStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<View
android:layout_marginTop="5dp"
android:background="@color/LightGrey"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
</LinearLayout>
I also faced the same issue having width and height is "dp". But, on my side it resolves by replacing scaleType from fitcenter to centerCrop.