Mohammad
Mohammad

Reputation: 3547

Theme.appcompat.light no resource found

I am using appcompat.light theme in my app, but I am getting an error msg error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. in three xml files: res/values/styles.xml , res/values-v11/styles.xml and res/values-v14/styles.xml, here is my app manifest code and styles.xml code:

manifest:

<?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>

here is my 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')
    }
}

Upvotes: 0

Views: 1073

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363677

First of all you should update your Android Studio to 1.x. and update your SDK Manager.

Then update your build.gradle.

Change:

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

in

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

Then

compileSdkVersion 8

in

compileSdkVersion 22

Then:

buildToolsVersion "18.1.0"

in

buildToolsVersion "22.0.0"

Finally add:

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

Upvotes: 1

Micky
Micky

Reputation: 5728

Did you add the appcompat support library to your project? E.g. in your build.gradle: compile 'com.android.support:appcompat-v7:22.0.0'

Upvotes: 1

Related Questions