找不到与给定名称“android:Theme.Material.Light.DarkActionBar”匹配的资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24529534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'
提问by Ramprasad
I try to change my HelloWorld Application holo theme to Material.Light.DarkActionBar theme(As said by What's new Android Development tools session). But I got following error. I try to change target SDK version is 21. But We didn't have 21 SDK in SDK Manager. In that session,they said,set style xml for v-21.
我尝试将我的 HelloWorld 应用程序全息主题更改为 Material.Light.DarkActionBar 主题(正如新的 Android 开发工具会话所说)。但是我遇到了以下错误。我尝试将目标 SDK 版本更改为 21。但是我们在 SDK Manager 中没有 21 SDK。在那个会议上,他们说,为 v-21 设置样式 xml。
values/styles.xml
值/样式.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
values-v21/styles.xml
值-v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
build.gradle
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ramapps.helloworld"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Error:
错误:
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/aapt package -f --no-crunch -I /Applications/Android Studio.app/sdk/platforms/android-20/android.jar -M /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/manifests/debug/AndroidManifest.xml -S /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/res/debug -A /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/assets/debug -m -J /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/generated/source/r/debug -F /Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/libs/app-debug.ap_ --debug-mode --custom-package com.ramapps.helloworld -0 apk
Error Code:
1
Output:
/Users/Ram_PC/Ram/MyDrive/My_Workspaces/Android_Studio_Workspace_L/HelloWorld/app/build/intermediates/res/debug/values-v21/values.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar'.
回答by yannickpulver
You can try to set the values in the build.gradle
like this (updated for API 25):
您可以尝试build.gradle
像这样设置值(针对 API 25 更新):
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 21 //oldest version you would like to support
targetSdkVersion 25
versionCode 1
versionName "1.0"
...
}
}
回答by Nicks
We can not install apps that target L Preview on anything but L devices.
我们无法在 L 设备以外的任何设备上安装针对 L Preview 的应用程序。
Changing res/values/styles.xml
, Theme.Material.Light
to Theme.Light
and following build.gradle
worked for me.
改变res/values/styles.xml
, Theme.Material.Light
toTheme.Light
和build.gradle
follow 对我有用。
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.example.android.market.licensing'
minSdkVersion 13
targetSdkVersion 20
versionCode 1
versionName '1.0'
}
Although Theme.Material.Light
is part of the 20sdk version but somehow it is not working for me.
虽然Theme.Material.Light
是 20sdk 版本的一部分,但不知何故它对我不起作用。
回答by Ajay Sharma
Set Target of Your Application to API Level 21 from AssemblyMenifest.xml or add <uses-sdk android:targetSdkVersion="21" android:minSdkVersion="19" />
tag to your AssemblyMenifest.xml
从 AssemblyMenifest.xml 将您的应用程序的目标设置为 API 级别 21 或将<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="19" />
标记添加到您的 AssemblyMenifest.xml
回答by Muhammad Ebad
I changed Theme.Material.Lightto Theme.Lightand it worked for me.
我将Theme.Material.Light更改为Theme.Light并且它对我有用。
回答by Jay Mayu
I think the problem here is that you need to set your buildToolsVersion
to pre Android L version.
我认为这里的问题是您需要将您的buildToolsVersion
Android L 版本设置为之前的版本。
Here my gradle
这是我的毕业证书
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 15
targetSdkVersion 19
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:support-v13:19.+'
}
Also make sure to change the styles.xml
as below
还要确保更改styles.xml
如下
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Light">
</style>
</resources>
This should resolve the problem.
这应该可以解决问题。