0

I'm using the latest Material Design library for android and following the this documentation to create BottomAppBar.

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".fragments.ARFragment">

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/blue"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Here's the exception. Full log is here.

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 com.google.android.material.shape.MaterialShapeDrawable.prepareCanvasForShadow(MaterialShapeDrawable.java:850)
    at com.google.android.material.shape.MaterialShapeDrawable.draw(MaterialShapeDrawable.java:746)
    at android.view.View.getDrawableRenderNode(View.java:20463)
    at android.view.View.drawBackground(View.java:20399)

I saw the other StackOverFlow threads similar to this exception but there was no answer for me because the exception is in the library.

I'm testing on Android P.

Burak
  • 87
  • 1
  • 12
  • Have you seen [this](https://stackoverflow.com/questions/50231950/what-is-the-best-alternative-to-canvas-cliprect-with-region-op-replace)? – Jordan Nov 26 '18 at 04:31

1 Answers1

1

Check this Include Google Maven repository in build.gradle.

allprojects {
repositories {
  jcenter()
  maven {
    url "https://maven.google.com"
  }
}
}

Place material components dependency in your build.gradle. Keep in mind that material version is regularly updating.

implementation 'com.google.android.material:material:1.0.0-alpha1'

Set compileSdkVersion, and targetSdkVersion to the latest API version targetting Android P which is 28.

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.xxx"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 0
    versionName "1"

}
mehul chauhan
  • 1,792
  • 11
  • 26