26

我尝试将我的 HelloWorld 应用程序全息主题更改为 Material.Light.DarkActionBar 主题(正如 What's new Android Development tools session 所说)。但我得到了以下错误。我尝试将目标 SDK 版本更改为 21。但我们在 SDK 管理器中没有 21 SDK。他们说,在那次会议上,为 v-21 设置样式 xml。

值/样式.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>

构建.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'.
4

5 回答 5

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"
    ...
  }
}
于 2014-07-03T06:57:55.733 回答
8

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

更改res/values/styles.xml, Theme.Material.LighttoTheme.Light和 followingbuild.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 版本的一部分,但不知何故它不适合我。

于 2014-08-04T06:23:23.267 回答
3

从 AssemblyMenifest.xml 将应用程序的目标设置为 API 级别 21 或将<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="19" />标签添加到您的 AssemblyMenifest.xml

于 2015-01-13T06:47:02.253 回答
2

我将Theme.Material.Light更改为Theme.Light,它对我有用。

于 2015-02-27T14:00:11.637 回答
1

我认为这里的问题是您需要将您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.+'
}

还要确保更改styles.xml如下

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

这应该可以解决问题。

于 2014-08-05T22:35:57.023 回答