0

我正在尝试将 Android 支持库 ( appcompat) 添加到仅分配用于 API 级别 10 的空项目中。

因此,我使用以下选项创建了 Android Studio 项目。

在此处输入图像描述

然后我在依赖项区域中添加支持库。

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 10
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 10
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.0'
}

然后我得到以下编译错误

MyAppProject/MyApp/build/exploded-bundles/ComAndroidSupportAppcompatV71800.aar/res/values-v14/values.xml
    Gradle: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Holo.SearchResult.Subtitle'.
    Gradle: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Holo.SearchResult.Title'.
    Gradle: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.PopupMenu.Large'.
    ...

MyAppProject/MyApp/build/exploded-bundles/ComAndroidSupportAppcompatV71800.aar/res/values-v11/values.xml
    Gradle: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'.
    Gradle: No resource found that matches the given name: attr 'android:windowActionBar'.
...
4

1 回答 1

1

您收到错误是因为您在项目中使用了来自 Android 3.0+ 的资源:'android:Theme.Holo'.

只需设置 targetSDKVersion >11。 在此处输入图像描述

了解 min/targetSdkVersion

于 2013-09-27T13:24:32.573 回答