Theme.appcompat.light找不到资源

时间:2015-03-23 15:39:50

标签: android eclipse android-appcompat

我在我的应用中使用了appcompat.light主题,但我在三个xml文件中收到错误信息error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.:res / values / styles.xml,res / values-v11 / styles.xml和res /values-v14/styles.xml,这是我的应用清单代码和styles.xml代码:

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="project.perfectdelivery"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

styles.xml

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

这是我的build.gradle:

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

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 8
    buildToolsVersion "18.1.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

2 个答案:

答案 0 :(得分:1)

您是否已将appcompat支持库添加到项目中? 例如。在build.gradle中:compile 'com.android.support:appcompat-v7:22.0.0'

答案 1 :(得分:1)

首先,您应该将Android Studio更新为1.x.并更新您的SDK Manager。

然后更新您的build.gradle

变化:

classpath 'com.android.tools.build:gradle:0.5.+'

in

classpath 'com.android.tools.build:gradle:1.1.0'

然后

compileSdkVersion 8

in

compileSdkVersion 22

然后:

buildToolsVersion "18.1.0"

in

buildToolsVersion "22.0.0"

最后添加:

dependencies {
    // Support Libraries
    compile 'com.android.support:appcompat-v7:22.0.0'
}