Search code examples
androidgradleandroid-support-librarychromecastandroid-appcompat

AppCompat / Chromecast in Android-L Preview


Situation:

I'm currently building a new version of my app for Android L and am also in the process of Chromecast integration. The app works fine, as long as I extend Theme.Material with my custom style, but doesn't show the Cast button.

Problem:

As soon as I change to Theme.AppCompat, it gives me the error:

Error:Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light.DarkActionBar'.

and the same goes for the the Holo Theme as well.

Here's my build.gradle (The libs folder is empty btw.):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.myapp.myapp"
    minSdkVersion 'android-L'
    targetSdkVersion 'android-L'
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:support-v4:+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:mediarouter-v7:+'
    compile 'com.google.android.gms:play-services:+'
}

Here is the relevant part of the values/styles.xml:

<style name="SK" parent="android:Theme.AppCompat.Light.DarkActionBar">

used to work with Theme.Holo.Light.DarkActionBar

and the values-v21/styles.xml:

<style name="SK" parent="@android:style/Theme.AppCompat.Light.DarkActionBar">

used to wirk with Theme.Material.Light.DarkActionBar

I already cleaned and rebuild the project, but it always goes back to showing me errors about a missing parent. As far as I could gather from similar questions, all relevant libraries are included and all use the newest version available. I also tried manually adding the libraries to the libs/ folder with no success. My SDK manager shows that everything is installed and up to date.

What am I missing here? Thanks in advance for your time.


Solution

  • Solution:

    It was actually rather simple. I referred to Theme.AppCompat with the android namespace, but should have left it out, so, instead of

    @android:style/Theme.AppCompat
    

    it should be

    @style/Theme.AppCompat
    

    This did show another error initially, about "Theme" not being found, but it compiled non the less.