Android java.lang.IllegalArgumentException:路径必须是凸的 [英] Android java.lang.IllegalArgumentException: path must be convex

查看:115
本文介绍了Android java.lang.IllegalArgumentException:路径必须是凸的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 7中的应用程序工作相同,而Android 8中的应用程序失败.

Same Application Work in Android 7 and Failed in Android 8.

在一项活动中,我正在从Fire-base数据库中检索数据.当Fire-base数据库为空时,没有错误发生,并且在有数据的情况下发生了错误,我搜索了错误但从未得到任何解决方案.

On an activity i am retrieving data from Fire-base database. when Fire-base database is empty then no error occurred and error occurred when it's have data's , I searched error but never got any solution for that.

logcat:-

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)
        at android.view.View.draw(View.java:19183)
        at android.view.View.updateDisplayListIfDirty(View.java:18142)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.draw(View.java:19195)
        at android.view.View.updateDisplayListIfDirty(View.java:18142)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.support.v7.widget.RecyclerView.drawChild(RecyclerView.java:4703)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.draw(View.java:19195)
        at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:4107)
        at android.view.View.updateDisplayListIfDirty(View.java:18142)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.updateDisplayListIfDirty(View.java:18133)
        at android.view.View.draw(View.java:18920)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4236)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4022)
        at android.view.View.draw(View.java:19195)
        at com.android.internal.policy.DecorView.draw(DecorView.java:788)
        at android.view.View.updateDisplayListIfDirty(View.java:18142)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:669)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:675)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:783)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:2992)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2806)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2359)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)

item_people.xml的代码

code of item_people.xml

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:weightSum="1"
        android:orientation="horizontal">

        <de.hdodenhof.circleimageview.CircleImageView
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/icon_avata"
            android:layout_width="0dp"
            android:layout_weight="0.15"
            android:layout_height="50dp"
            android:layout_margin="10dp"
            android:background="@mipmap/ic_launcher_round"
            app:civ_border_color="@color/colorPrimary" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginStart="10dp"
            android:layout_weight="0.8"
            android:orientation="vertical"
            android:layout_marginLeft="10dp"
            tools:ignore="RtlHardcoded">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:paddingTop="5dp">

                <TextView
                    android:id="@+id/people_name"
                    android:layout_width="0dp"
                    android:text="link"
                    android:layout_height="match_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/txtTime"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="0.3"
                    android:text=""
                    android:gravity="center_vertical|right"
                    android:paddingRight="10dp"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    tools:ignore="RtlHardcoded,RtlSymmetry" />
            </LinearLayout>

            <TextView
                android:id="@+id/txtNickname"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:text="name"
                android:ellipsize="end"
                android:gravity="center_vertical"
                android:lines="1"
                android:paddingBottom="10dp"
                android:textAppearance="?android:attr/textAppearanceSmall" />
        </LinearLayout>
    </LinearLayout>
</android.support.v7.widget.CardView>

推荐答案

看看堆栈跟踪,前几行讲述了一个故事:

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)

  • 第三行提到 AdaptiveIconDrawable
  • 第7行提到 View.drawBackground()
  • 搜索 AdaptiveIconDrawable 告诉我们,这是Android 8的一项新功能:

    Searching for AdaptiveIconDrawable tells us that this is a new Android 8 feature:

    这说明了为什么您的代码可在Android 7上运行但在8上崩溃的原因.在Android 7上,系统不使用自适应图标,而是使用普通的PNG.在Android 8上,如果您提供了自适应图标,它将使用自适应图标.

    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...

    查看您的 CardView 布局,您将启动器图标(在Android 8上可能是您的 AdaptiveIconDrawable )设置到 CircleImageView 背景.

    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.

    发生崩溃的地方-图标无效或 CircleImageView 以这种方式使用时不支持它.

    That is where the crash is happening - either the icon is not valid, or CircleImageView does not support it when used this way.

    一种解决方法是在您的应用中包含一个PNG图标,在这种情况下,该图标将作为背景使用.

    A fix would be to include a PNG icon in your app that will work as the background in this case.

    这篇关于Android java.lang.IllegalArgumentException:路径必须是凸的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆