Android Java.lang.illegalargumentexception: Path Must Be Convex
Solution 1:
Looking at the stack trace, the first few lines tell a story:
java.lang.IllegalArgumentException: path must be convex
at android.graphics.Outline.setConvexPath(Outline.java:284)
at android.graphics.drawable.AdaptiveIconDrawable.getOutline(AdaptiveIconDrawable.java:387)
at android.view.ViewOutlineProvider$1.getOutline(ViewOutlineProvider.java:38)
at android.view.View.rebuildOutline(View.java:14960)
at android.view.View.setBackgroundBounds(View.java:19416)
at android.view.View.drawBackground(View.java:19381)
- 3rd line mentions
AdaptiveIconDrawable
- 7th line mentions
View.drawBackground()
Searching for AdaptiveIconDrawable
tells us that this is a new Android 8 feature:
That explains why your code works on Android 7 but crashes on 8. On Android 7 the system does not use adaptive icons, but instead uses a normal PNG. On Android 8 it will use an adaptive icon if you have supplied one.
There seems to be something wrong with the new icon, or it just doesn't work where you are using it.
Next we need to find out what background is breaking...
Looking at your CardView
layout, you are setting your launcher icon (on Android 8 this is likely to be your AdaptiveIconDrawable
) onto your CircleImageView
background.
That is where the crash is happening - either the icon is not valid, or CircleImageView
does not support it when used this way.
A fix would be to include a PNG icon in your app that will work as the background in this case.
Solution 2:
Assuming your icon is set up properly, try setting the icon for CircleImageView using android:src
instead of android:background
.
Post a Comment for "Android Java.lang.illegalargumentexception: Path Must Be Convex"