情况:
我目前正在为 Android L 构建我的应用程序的新版本,并且还在 Chromecast 集成过程中。
只要我使用自定义样式扩展 Theme.Material,该应用程序就可以正常工作,但不显示 Cast 按钮。
问题:
一旦我更改为 Theme.AppCompat,它就会给我错误:
Error:Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light.DarkActionBar'.
Holo 主题也是如此。
这是我的 build.gradle (顺便说一句,libs 文件夹是空的。):
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:+'
}
这是的相关部分值/样式.xml :
<style name="SK" parent="android:Theme.AppCompat.Light.DarkActionBar">
用于使用 Theme.Holo.Light.DarkActionBar
和 值-v21/styles.xml :
<style name="SK" parent="@android:style/Theme.AppCompat.Light.DarkActionBar">
曾经与 Theme.Material.Light.DarkActionBar 一起使用
我已经清理并重建了项目,但它总是回到向我显示有关缺少父级的错误。
据我从类似问题中收集到的,所有相关库都包括在内,并且都使用可用的最新版本。
我还尝试手动将库添加到 libs/文件夹,但没有成功。
我的 SDK 管理器显示所有内容都已安装并且是最新的。
我在这里想念什么?
在此先感谢您的时间。
最佳答案
解决方案:
其实很简单。我用 android 命名空间提到了 Theme.AppCompat,但应该把它排除在外,所以,而不是
@android:style/Theme.AppCompat
它应该是
@style/Theme.AppCompat
最初确实显示了另一个错误,关于未找到“主题”,但它编译得并不少。
关于android - Android-L 预览版中的 AppCompat/Chromecast,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24946858/