未找到与给定名称匹配的资源';android:Theme.Material.Light.DarkActionBar';

未找到与给定名称匹配的资源';android:Theme.Material.Light.DarkActionBar';,android,android-5.0-lollipop,Android,Android 5.0 Lollipop,我尝试将HelloWorld应用程序holo主题更改为Material.Light.DarkActionBar主题(正如新版Android开发工具课程所述)。但我犯了以下错误。我尝试将目标SDK版本更改为21。但我们在SDK管理器中没有21个SDK。他们说,在那个会议中,为v-21设置样式xml values/styles.xml <resources> <!-- Base application theme. --> <style name="A

我尝试将HelloWorld应用程序holo主题更改为Material.Light.DarkActionBar主题(正如新版Android开发工具课程所述)。但我犯了以下错误。我尝试将目标SDK版本更改为21。但我们在SDK管理器中没有21个SDK。他们说,在那个会议中,为v-21设置样式xml

values/styles.xml

<resources>

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

</resources>
<?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>
错误:

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

您可以尝试在
build.gradle
中这样设置值(针对API 25更新):


我们无法在除L设备以外的任何设备上安装以L Preview为目标的应用程序

res/values/styles.xml
Theme.Material.Light
更改为
Theme.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版本的一部分,但不知何故它对我不起作用。

我认为这里的问题是您需要将
buildToolsVersion
设置为Android L之前的版本

这是我的毕业证书

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.+'
}
还要确保更改
style.xml
,如下所示

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


这应该可以解决问题。

将应用程序的目标从AssemblyMenifest.xml设置为API级别21,或者将
标记添加到AssemblyMenifest.xml

我将Theme.Material.Light更改为Theme.Light,它对我起到了作用

但我们在SDK管理器中没有21个SDK,这说明了什么?此外,您可能还应该为API版本更改清单XML。@他们在SDK管理器中提到的ThorstenDittmar与Android L(API 20,L预览)类似。此外,我还尝试在清单XML中设置minSDK版本。但并非worksAFAIK API20或多或少适用于可穿戴设备(正如您在错误中看到的,它使用的是Android-4.4W)。将compileSdkVersion更改为“android-L”可能会有所帮助。@harism我也有同样的问题,我正在尝试使用buildToolsVersion“19.1.0”未对其进行测试,但我可以更改为
minSdkVersion 16
,它仍然可以正常工作。知道我们如何使用phonegap build来实现这一点吗?使用
返回相同的错误,但它可以与
Theme.Holo.Light一起使用
我建议修复代码段中的奇数括号。谢谢!是的,这对我也很有用,别忘了这样做:“tns准备android”,然后是“tns准备android”
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.+'
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="android:Theme.Light">
    </style>
</resources>