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

Ram*_*sad 26 android android-5.0-lollipop

我尝试将我的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>
Run Code Online (Sandbox Code Playgroud)

值-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>
Run Code Online (Sandbox Code Playgroud)

的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'])
}
Run Code Online (Sandbox Code Playgroud)

错误:

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'.
Run Code Online (Sandbox Code Playgroud)

yan*_*ver 29

您可以尝试设置这样的值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"
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)


Nic*_*cks 8

除L设备外,我们无法安装以L Preview为目标的应用.

更改res/values/styles.xml,Theme.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'
    }
Run Code Online (Sandbox Code Playgroud)

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