【问题标题】:how to solve render problem Path.op() not supported?如何解决不支持的渲染问题 Path.op()?
【发布时间】:2020-05-05 15:47:23
【问题描述】:

如何解决此错误: 渲染问题 不支持 Path.op()

我尝试强制刷新布局,重启,更新Android Studio,停止杀毒一段时间,但问题仍然存在。

令人惊讶的是我能够编译和运行应用程序,但是如何摆脱这个错误呢?

我正在使用:

  • Android Studio 3.5.3
  • Android SDK 工具 29.0.2
  • Android SDK 平台 Android 10.0 (Q) Android SDK 平台 29
  • 默认 OpenJDK 平台二进制文件

重现错误:

  • 使用空活动创建新的 Android 项目
  • 将布局替换为以下布局:

    <?xml version="1.0" encoding="utf-8"?>    <androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/parent_view"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity"
        android:background="@android:color/white">
    
    
        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <include layout="@layout/toolbar" />
    
        </com.google.android.material.appbar.AppBarLayout>
    
        <androidx.core.widget.NestedScrollView
            android:id="@+id/nested_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:scrollbars="none"
            android:scrollingCache="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
    
                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="2dp">
    
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
    
                        <androidx.viewpager.widget.ViewPager
                            android:id="@+id/pager"
                            android:layout_width="match_parent"
                            android:layout_height="250dp"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentStart="true"
                            android:layout_alignParentTop="true"
                            android:background="@android:color/darker_gray" />
    
                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:layout_centerHorizontal="true"
                            android:orientation="vertical"
                            android:paddingBottom="16dp"
                            android:paddingLeft="12dp"
                            android:paddingRight="12dp"
                            android:paddingTop="14dp">
    
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:orientation="vertical">
    
                                <TextView
                                    android:id="@+id/title"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="Title is going here"
                                    android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                                    android:textColor="@android:color/white" />
    
    
    
    
    
                                <TextView
                                    android:id="@+id/brief"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text=" Location"
                                    android:textAppearance="@style/TextAppearance.AppCompat.Small"  />
    
    
                            </LinearLayout>
    
                            <LinearLayout
                                android:id="@+id/layout_dots"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentBottom="true"
                                android:layout_alignParentEnd="true"
                                android:layout_alignParentRight="true"
                                android:layout_gravity="end"
                                android:gravity="center"
                                android:orientation="horizontal" />
    
    
                        </RelativeLayout>
    
                    </RelativeLayout>
    
                </androidx.cardview.widget.CardView>
    
                <View
                    android:layout_width="0dp"
                    android:layout_height="16dp" />
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="16dp"
                    android:orientation="vertical">
    
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Description"
                        android:textAppearance="@style/TextAppearance.AppCompat.Large"
                        android:textColor="@android:color/darker_gray" />
    
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="6dp"
                        android:lineSpacingExtra="4dp"
                        android:text="very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum very_long_lorem_ipsum "
                        android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
                        android:textColor="@android:color/darker_gray"/>
    
    
                </LinearLayout>
    
                <View
                    android:layout_width="0dp"
                    android:layout_height="8dp" />
    
    
            </LinearLayout>
    
        </androidx.core.widget.NestedScrollView>
    

【问题讨论】:

    标签: android android-studio layout render


    【解决方案1】:

    我昨天遇到了同样的问题。我的与

    有关

    com.google.android.material.appbar.AppBarLayout

    组件。 我不知道具体原因,但添加android:background="..." 即可解决。

    【讨论】:

      【解决方案2】:

      我也遇到了同样的问题。原因是,新版本的材料组件与此错误捆绑在一起。所以,我尝试将 Gradle 构建脚本中的版本替换为支持Path.op() 的版本。

      所以,您唯一需要做的就是用这个替换 Gradle 构建脚本中的依赖项:

      实现'com.google.android.material:material:1.2.0-alpha02'

      【讨论】:

      • 也为我工作。按钮图标未显示在布局上,这解决了问题。
      • 当前最新版本:'com.google.android.material:material:1.3.0'好像已经修复了这个bug
      • 解决方案:使用新的布局渲染引擎。为此,请转到设置 -> 实验性 -> 选中“使用新的布局渲染引擎”
      【解决方案3】:

      我遇到了同样的问题。当我运行应用程序时,问题得到了改善。我认为当你清理并重建你的项目时,这个问题会得到改善。

      【讨论】:

        【解决方案4】:

        在使用芯片时遇到同样的问题,它在布局编辑器中不可见。通过更改解决它

        implementation 'com.google.android.material:material:1.2.0-alpha03'
        

        implementation 'com.google.android.material:material:1.2.0-alpha02'
        

        【讨论】:

          【解决方案5】:

          通过替换 Gradle Build 中的材料组件实现解决了问题(在 App 级别)

          com.google.android.material:material:1.2.0-alpha05
          

          com.google.android.material:material:1.2.0-alpha02
          

          【讨论】:

            【解决方案6】:

            替换

            实现fileTree(dir: 'libs', include: ['*.jar'])

            api 'com.google.android.material:material:1.2.0-alpha06'
            

            实现fileTree(dir: 'libs', include: ['*.jar'])

            api 'com.google.android.material:material:1.2.0-alpha02'
            

            【讨论】:

              【解决方案7】:

              有点晚了,但是

              implementation 'com.google.android.material:material:1.2.0-alpha06'

              工作正常,因此无需再降级到 alpha02。

              【讨论】:

              • 不适合我。已经使用 alpha-06 并且在清除、重建后出现同样的问题。
              • 刚刚试了1.2.0-rc01,bug还在。
              • 当前最新版本:'com.google.android.material:material:1.3.0' 似乎工作正常
              【解决方案8】:

              遇到此问题的任何人只需降级或升级您的材料设计依赖项 到

               implementation 'com.google.android.material:material:1.2.0-alpha02'
              

              在渲染方面似乎更稳定,尤其是如果您使用的是 android studio V3.4 及更高版本。 我有时会想念日食

              【讨论】:

                【解决方案9】:

                如果您在内部使用“ImageView”,请确保它们的 XML 代码是这样的。

                您的默认生成可能如下所示。 Wrong XML Code

                将 (tools:srcCompat="@drawable/img_avatar") 更改为 (android:src="@drawable/img_avatar"),如下所示 Correct XML Code

                我认为它会为您解决这个问题。谢谢。

                其他细节:- My Android Studio Version My Gradle Dependencies

                当我尝试在 ImgView 中显示 PNG 时遇到了这个问题。

                【讨论】:

                  【解决方案10】:

                  刚刚更新:版本 1.3.0-rc01 已经发布。你可以使用

                  implementation 'com.google.android.material:material:1.3.0-rc01'

                  【讨论】:

                  • 解决方案:使用新的布局渲染引擎。为此,请转到设置 -> 实验性 -> 选中“使用新的布局渲染引擎”
                  【解决方案11】:

                  该错误似乎已在最新版本的材料组件中得到解决,目前是:

                  implementation 'com.google.android.material:material:1.3.0'
                  

                  【讨论】:

                    【解决方案12】:

                    使用新的布局渲染引擎帮助解决了我的问题。转到设置 -> 实验性 -> 使用新的布局渲染引擎

                    【讨论】:

                      【解决方案13】:

                      只是不要定义版本: 实施 'com.google.android.material:material' 它对我有用。

                      【讨论】:

                        【解决方案14】:

                        对我来说,只有在从 androidx.recyclerview.widget.RecyclerView 中删除 fastScroll 设置后,才解决了问题。

                        【讨论】:

                          【解决方案15】:

                          更改依赖项对我有用:

                          implementation 'com.google.android.material:material:1.2.0'

                          【讨论】:

                            【解决方案16】:

                            使用实验性渲染引擎,它为我解决了这个问题。首先由Carlos推荐。

                            这是在 android studio 中的操作方法。

                            转到文件 > 设置

                            现在将显示设置窗口。
                            转到 Experimental 选项卡并选中/勾选 使用新的布局渲染引擎

                            就是这样!

                            【讨论】:

                              猜你喜欢
                              • 2021-01-11
                              • 1970-01-01
                              • 1970-01-01
                              • 2021-10-04
                              • 2010-10-23
                              • 2016-12-31
                              • 2010-09-17
                              • 2017-11-16
                              • 2021-03-05
                              相关资源
                              最近更新 更多