找不到与给定名称相匹配的资源“android:Theme.Material.Light.DarkActionBar”

我尝试将我的HelloWorld应用程序holo主题更改为Material.Light.DarkActionBar主题(正如新的Android开发工具会话所述)。 但我有以下错误。 我尝试更改目标SDK版本是21.但是我们在SDK Manager中没有21 SDK。 在那次会议上,他们说,为v-21设置风格xml。

价值观/ styles.xml

<resources> <!-- Base application theme. --> <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> </resources> 

值-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

 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 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'. 

Solutions Collecting From Web of "找不到与给定名称相匹配的资源“android:Theme.Material.Light.DarkActionBar”"

您可以尝试像这样设置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" ... } } 

除了L设备之外,我们无法安装定位L预览的应用程序。

res/values/styles.xmlTheme.Material.LightTheme.Light ,然后build.gradle为我工作。

 android { compileSdkVersion 20 buildToolsVersion '20.0.0' defaultConfig { applicationId 'com.example.android.market.licensing' minSdkVersion 13 targetSdkVersion 20 versionCode 1 versionName '1.0' } 

虽然Theme.Material.Light是20sdk版本的一部分,但不知何故,它不适合我。

从AssemblyMenifest.xml中将您的应用程序的目标设置为API Level 21,或者在您的AssemblyMenifest.xml文件中添加<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="19" />

我将Theme.Material.Light更改为Theme.Light ,它为我工作。

我认为这里的问题是你需要将你的buildToolsVersion设置为Android L版本。

在这里,我的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.+' } 

另外请确保如下更改styles.xml

 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="android:Theme.Light"> </style> </resources> 

这应该可以解决问题。