No resource found - Theme.AppCompat.Light.DarkActionBar
Asked Answered
C

17

151

I used ActionBar Style Generator, and now trying to use into my app, but getting :

error: Error retrieving parent for item: No resource found that matches the given name '@style/ Theme.AppCompat.Light.DarkActionBar'.

i am using android-support-v7-appcompat.jar lib inside libs folder

my target is to make my app compatible 2.3 or above

Convoy answered 20/2, 2014 at 7:19 Comment(3)
did you add the jar to libs folder?Perceptual
yes android-support-v7-appcompat.jarConvoy
@AbrahimNeil : see Can't Find Theme.AppCompat.Light for New Android ActionBar Support maybe help youFranzoni
P
101

AppCompat is a library project. You need to reference the library project in your android project.

Check the topic Adding libraries with resources.

Update

Adding material theme should be the way. Check https://material.io/develop/android/docs/getting-started for more details.

Perceptual answered 20/2, 2014 at 7:21 Comment(11)
already placed android-support-v7-appcompat.jar to libs folderConvoy
@AbrahimNeil that is not the right way. its a library project and hence must be referenced just like google play servicesPerceptual
when i am importing android-support-v7-appcompat.jar getting Unable to resolve target android-16 is it requires ?Convoy
@AbrahimNeil follow #15804761 assuming you are using eclipse idePerceptual
i ticked as useful both this and that, my only concern was is it requires ?Convoy
you can check it to 17 if you have or download 16 if you want to.Perceptual
i am just using android 19 :( this even without Google APIsConvoy
let us continue this discussion in chatPerceptual
adding implementation 'com.android.support:appcompat-v7:28.0.0', under dependencies solved my problem.Lever
Thanks, Hilal, adding that in the project's Gradle file worked for me.Overlooker
implementation 'com.google.android.material:material:1.3.0' for androidxThinker
C
34

If you're using Eclipse, then add the reference library into your project as the following steps:

  1. Right-click your project in the Project Explorer View.
  2. Click Properties.
  3. Click Android in the Properties window.
  4. In the Library group, click Add...
    • See the image below.
  5. Select the library. Click OK.
  6. Click the OK button again in the Properties window.

The "Add" button in the project Properties window, Android section, Library group.

Cordy answered 20/2, 2014 at 7:26 Comment(2)
how do you know op is using eclipse not android studio?. the snap posted is for eclipse.Perceptual
@Perceptual sorry forget to mention itCordy
P
33

If you are using Android Studio then just add the dependency

dependencies {
     implementation 'com.android.support:appcompat-v7:25.0.1'
}

to app/build.gradle. And that will work

Puga answered 13/8, 2015 at 5:58 Comment(3)
Um... it doesn't work... it still won't resolve android:Theme.AppCompat.* in my styles.xml file.Mutilate
I just replaced implementation 'com.android.support:appcompat-v7:28.0.0' by implementation 'com.android.support:appcompat-v7:25.0.1' and now it works... but why?Gifferd
@Gifferd I believe Android changed the themes for 28+ and Light.DarkActionBar isn't available anymore.Yokel
S
14

For anyone out there using VS2015, I was getting this error too, and it turns out I hadn't added the library to the project...

Install-Package Xamarin.Android.Support.v7.AppCompat
Shandishandie answered 7/10, 2016 at 14:23 Comment(1)
I got this after starting a fresh project in VS2019 and Building it. Simply doing a "Rebuild Solution" without having to install anything else resolved the errors.Ancier
B
8

If you are using Eclipse just copying android-support-v7-appcompat.jar to libs folder will not work if you are going to use resources.

Follow steps from here for "Adding libraries with resources".

Bagehot answered 20/2, 2014 at 7:26 Comment(0)
D
8

A simple solution - replace contents this file (/res/values/styles.xml) to this is text:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

Diffluent answered 16/9, 2015 at 11:34 Comment(2)
"Error retrieving parent for item: No resource found that matches the given name 'AppBaseTheme'."Scrivener
This is not AppCompat.Verbalism
T
5
dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

compile has been replaced by implementation, don't know why.

Tenpenny answered 4/2, 2019 at 22:40 Comment(1)
This is the solution for me.Crittenden
I
4

In my case, I took an android project from one computer to another and had this problem. What worked for me was a combination of some of the answers I've seen:

  • Remove the copy of the appcompat library that was in the libs folder of the workspace
  • Install sdk 21
  • Change the project properties to use that sdk build enter image description here
  • Set up and start an emulator compatible with sdks 21
  • Update the Run Configuration to prompt for device to run on & choose Run

Mine ran fine after these steps.

Instillation answered 9/3, 2015 at 15:14 Comment(0)
S
4
dependencies {

    compile 'com.android.support:appcompat-v7:23.0.0'

}

This worked for me... in Android Studio...

Skye answered 18/8, 2015 at 21:44 Comment(0)
G
3

Using Visual Studio 2015 (Windows7) + Xamarin had this error and after trying multiple things (installing packages, download android_m2repository_r10.zip...) ended removing the full Xamarin folder inside

C:\Users\<my user>\AppData\Local

After that, Rebuild the application in VS and errors disappeared.

Golda answered 17/2, 2016 at 16:38 Comment(2)
This worked for me :) Note: Using Visual Studio Enterprise. 2017 15.8 Preview 3.0Rawalpindi
Worked for me as well, using VS 2017.Criswell
E
3

make sure there is a v7 directory in your sdk, I thought having the 'Android Support Library' (in Extras) was sufficient. Turns out I was missing the 'Local Maven repository for Support Libraries (extras;android;m2repository)' Studio found that actually and fixed the gradle dependencies. using gradle to build then worked. $ cat app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "pat.example.com.gdbdemo"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.2.1'
}
Effusion answered 19/3, 2016 at 0:17 Comment(0)
C
2

If you are using the Android.mk to build then use the USE_AAPT2, which link in the built resource from the AAR.

Add below line in Android.mk file:

LOCAL_USE_AAPT2 := true

Catherine answered 8/2, 2019 at 0:8 Comment(0)
C
1
  1. Update your SDK in the manager and be sure to include Android support library in extra's
  2. Go to SDK in file explorer (Finder on mac) track down the extra's folder (..\sdk\extras\android\support\v7\appcompat\res\values on Windows). Somewhere in there is a themes.xml and themes_base.xml. Copy both of these files.
  3. In your project paste the files into 'values' directory
Cerallua answered 31/1, 2016 at 8:56 Comment(1)
Copying themes_base.xml into res/values solved the original problem but resulted in other unresolved references.Scutum
S
0

In Eclipse: When importing a support library as a project library following the instructions at Adding Support Libraries, don't forget to check the option "Copy proyects into workspace"!

Septimal answered 22/5, 2015 at 2:33 Comment(0)
P
0

I had this same problem. None of the solutions listed here helped my situation. As it turns out, I was importing the parent folder for a project into Android Studio 1.5, rather than the project folder itself. This threw Gradel into a tizzy. Solution was to import the project folder instead.

Pentacle answered 13/12, 2015 at 22:6 Comment(0)
G
0

If you are using Visual Studio for MAC, fix the problem clicking on Project > Restoring Nutget packages

Glob answered 17/6, 2019 at 4:15 Comment(0)
S
-1

In xamarin if you face this issue when you add any new sdk. The simple solution is Open your styles file and add this line.

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>

It's better solution rather than adding appcompat.

Selfmoving answered 22/4, 2020 at 4:51 Comment(1)
This would mean that your app would be using the old Android styling, instead of Material Design.Thorianite

© 2022 - 2024 — McMap. All rights reserved.