title: Why am I getting java.lang.IllegalArgumentException: background can not be translucent: #0 when using MediaRouteButton?
body: <p>I'm trying to cast my app to Chromecast. I've started with adding a button, following the <a href="https://developers.google.com/cast/docs/android_sender_integrate" rel="nofollow noreferrer">https://developers.google.com/cast/docs/android_sender_integrate</a> guide.</p>
  
  <p>After I have added the MediaRouteButton, I get:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: background can not be translucent: #0
  at android.support.v4.graphics.ColorUtils.calculateContrast(ColorUtils.java:93)
  at android.support.v7.app.MediaRouterThemeHelper.getControllerColor(MediaRouterThemeHelper.java:88)
  at android.support.v7.app.MediaRouterThemeHelper.getStyledRouterThemeId(MediaRouterThemeHelper.java:185)
  at android.support.v7.app.MediaRouterThemeHelper.createThemedContext(MediaRouterThemeHelper.java:60)
  at android.support.v7.app.MediaRouteButton.&lt;init&gt;(MediaRouteButton.java:124)
  at android.support.v7.app.MediaRouteButton.&lt;init&gt;(MediaRouteButton.java:120)
  at java.lang.reflect.Constructor.newInstance(Native Method) 
  at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
  at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
  at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
  at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
  at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:408) 
  at android.app.Activity.setContentView(Activity.java:2198) 
  </code></pre>
  
  <p>I have searched SO, and have found another, similar question, where a commenter asked to add background tag to the xml entry of MediaRouteButton. Here's my layout xml:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/mdb_reader"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
     &lt;LinearLayout
          android:id="@+id/mdb_book_list"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;android.support.v7.app.MediaRouteButton
              android:id="@+id/media_route_button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:background="@color/black"
              android:layout_weight="1"
              android:mediaRouteTypes="user"
              android:visibility="gone" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>(I have two layouts nested because it's used programmatically, anyway I have already tried to move the MediaRouteButton higher and it didn't help).</p>
  
  <p>I've also seen some tips regarding theme, here's my <code>AndroidManifest.xml</code> <code>application</code> entry:</p>
  
  <pre><code>&lt;application
      android:allowBackup="true"
      android:hardwareAccelerated="true"
      android:icon="@drawable/icon"
      android:label="@string/app_name"
      android:background="@android:color/black"
      android:theme="@style/AppTheme"&gt;
  </code></pre>
  
  <p><strong>vales/styles.xml</strong></p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt;
      &lt;/style&gt;
  
      &lt;style name="AppTheme" parent="AppBaseTheme"&gt;
      &lt;/style&gt;
  
      &lt;style name="Theme.CastVideosTheme" parent="AppBaseTheme"&gt;
          &lt;item name="mediaRouteTheme"&gt;@style/CustomMediaRouterTheme&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomMediaRouterTheme" parent="Theme.MediaRouter"&gt;
          &lt;item name="mediaRouteButtonStyle"&gt;@style/CustomMediaRouteButtonStyle&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton"&gt;
          &lt;item name="buttonTint"&gt;@color/black&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>values-v11/styles.xml</strong></p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt;
      &lt;/style&gt;
      &lt;style name="Theme.CastVideosTheme" parent="AppBaseTheme"&gt;
          &lt;item name="mediaRouteTheme"&gt;@style/CustomMediaRouterTheme&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomMediaRouterTheme" parent="Theme.MediaRouter"&gt;
          &lt;item name="mediaRouteButtonStyle"&gt;@style/CustomMediaRouteButtonStyle&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton"&gt;
          &lt;item name="buttonTint"&gt;@color/black&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>values-v14</strong></p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt;
      &lt;/style&gt;
      &lt;style name="Theme.CastVideosTheme" parent="AppBaseTheme"&gt;
          &lt;item name="mediaRouteTheme"&gt;@style/CustomMediaRouterTheme&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomMediaRouterTheme" parent="Theme.MediaRouter"&gt;
          &lt;item name="mediaRouteButtonStyle"&gt;@style/CustomMediaRouteButtonStyle&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton"&gt;
          &lt;item name="buttonTint"&gt;@color/black&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Looks to me like everything should work, but I still get the damn error.</p>
  
  <p>I'm using Android 26 to build.</p>