android android-studio-3.0

android - java.lang.IllegalArgumentException: Region.Op no válido: solo INTERSECT y DIFFERENCE en el error de fondo del botón



android-studio-3.0 (5)

ACTUALIZAR

La solución para esto se incluirá en Android Studio 3.5 Canary 2.

java.lang.IllegalArgumentException: Region.Op no válido: solo INTERSECT y DIFERENCIA

El problema con targetSdkVersion 28

Parece que esto comenzó a aplicarse en P: https://developer.android.com/reference/android/graphics/Canvas#clipRect(android.graphics.RectF,%20android.graphics.Region.Op)

también reportado aquí

Solución temporal para su caso.

Utilizar

<corners android:radius="8dp"/>

en lugar de

<corners android:bottomRightRadius="8dp" android:bottomLeftRadius="8dp" android:topRightRadius="8dp" android:topLeftRadius="8dp"/>

Falla de fondo del botón de Android

cuando intento agregar

android:background="@drawable/roundedbutton"

en el .xml

<Button android:id="@+id/button_stop" style="@android:style/Widget.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@drawable/roundedbutton" android:layout_weight="1" android:text="stop" android:textSize="18sp" />

el roundedbutton.xml

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/colorPrimary" /> <corners android:bottomRightRadius="8dp" android:bottomLeftRadius="8dp" android:topRightRadius="8dp" android:topLeftRadius="8dp"/> </shape>

el botón quedó en blanco y Android Studio 3.2.1 da un error

java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed at android.graphics.Canvas.checkValidClipOp(Canvas.java:779) at android.graphics.Canvas.clipRect(Canvas.java:826) at android.view.ViewGroup_Delegate.drawShadow(ViewGroup_Delegate.java:86) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:58) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw_Original(View.java:20075) at android.view.View_Delegate.draw(View_Delegate.java:68) at android.view.View.draw(View.java:19849) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw_Original(View.java:20075) at android.view.View_Delegate.draw(View_Delegate.java:68) at android.view.View.draw(View.java:19849) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw_Original(View.java:20075) at android.view.View_Delegate.draw(View_Delegate.java:68) at android.view.View.draw(View.java:19849) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw_Original(View.java:20210) at android.view.View_Delegate.draw(View_Delegate.java:56) at android.view.View.draw(View.java:20177) at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:405) at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:552) at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:426) at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:108) at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154) at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136) at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$5(RenderTask.java:671) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Gracias.


El mismo problema ocurre al final, se solucionó ahora Cambie el targetSdkVersion 28 to 27 en build.gradle . Gracias


Esto es lo que me lo arregló:

.setCropShape(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? CropImageView.CropShape.RECTANGLE : CropImageView.CropShape.OVAL)


Prueba esto

<shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="2dp" android:color="@color/black" /> <solid android:color="@color/black" /> <corners android:radius="7dp" /> </shape>


intente eliminando "style =" @ android: style / Widget.Button "".

<Button android:id="@+id/button_stop" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@drawable/roundedbutton" android:layout_weight="1" android:text="stop" android:textSize="18sp" />