17

How to use properly Android Support Library because i have this error in my manifest file:

android:theme="@style/Theme.AppCompat.Light.DarkActionBar"

error: Error: No resource found that matches the given name 
(at 'theme' with value '@style/Theme.AppCompat.Light.DarkActionBar').
AndroidManifest.xml /ttab   line 39 Android AAPT Problem

My friend did this implementing for me previously on other computer, now i have to do this alone. Please help me:)

I am using ADT

My 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="android:Theme.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>

    <style name="Theme.AppCompat.Light">
     <!-- theme customizations here. -->
    </style>


    <style name="Theme.AppCompat.Light.DarkActionBar" parent="Theme.AppCompat.Light">
      <!-- theme customizations here. -->
    </style>


</resources>
Jerry
  • 181
  • 1
  • 1
  • 5
  • 1
    Import the AppCompat Library project (support lib v7) in your eclipse. See this - http://developer.android.com/tools/support-library/index.html – Varun Aug 21 '13 at 18:09
  • i did this before, but the problem has not been solved – Jerry Aug 21 '13 at 18:11
  • Have you added the appcompat project as a library project in your app? – Varun Aug 21 '13 at 18:13
  • i have some, i have done this using official instructions from docs – Jerry Aug 21 '13 at 18:16
  • 2 things. 1.) Do you have your appcompat project marked as library project? If not then right click on appcompat in eclipse, selecte android and check isLibrary. 2.) Right click on your porject, add the appcompat as a library project to it and do a clean build. Thats All.. All the necessary styles are contained in the appcompat project(appcompat/res/values/styles).. – Varun Aug 21 '13 at 18:32
  • 1) yes 2) i did exacly as you wrote me but i have something like that: http://s14.postimg.org/dnh3n9f75/android.jpg – Jerry Aug 21 '13 at 18:39
  • yes, exactly. remove the library app from there because it is incorrectly referenced. Remove it and add again. – Varun Aug 21 '13 at 18:41
  • but before that import it into eclispe – Varun Aug 21 '13 at 18:42
  • please explain me: i have to remove my library project or only library refference? – Jerry Aug 21 '13 at 18:44
  • remove the library reference and add it again. The 'x' mark in red color would become a 'check' mark if it is correctly referenced. – Varun Aug 21 '13 at 18:45
  • check this image with a green check mark - http://imagebin.org/268317 – Varun Aug 21 '13 at 18:48
  • i made it, but no result... i have even added again my library project in order to do this what you wrote above... – Jerry Aug 21 '13 at 18:54
  • 3
    Heh masters :) I have solved this issue. Problem was that my appcompact library projest has been located in different location. On importing I have to check "Copy project into workspace" thats all! – Jerry Aug 21 '13 at 19:50
  • Here is the right and illistrated answer: http://stackoverflow.com/questions/18025942/how-do-i-add-a-library-android-support-v7-appcompat-in-intellij-idea – Serge Populov Oct 18 '13 at 18:18

5 Answers5

16

In "android-support-v7-appcompat" project:

  • Delete “android-support-v7-appcompat” from Package explorer.
  • Import again and check “Copy into workspace”
  • In Properties -> Android -> in Project build target, uncheck Android 2.2 and check Android 4.1.2
  • In Java build path, uncheck if you have any .jar library, and uncheck the Dependences

In other hand, the project that uses “android-support-v7-appcompat”:

  • In Properties -> Android add the library, but uncheck "IsLibrary”.
  • In Android -> Project build tarjet check Android 4.0.
  • In "Java Build Path" -> Order and Export -> Unchecked the .jar library
  • Finally do a “Project -> Clean” both projects
Qiu
  • 5,651
  • 10
  • 49
  • 56
Hernaldo Gonzalez
  • 1,977
  • 1
  • 21
  • 32
  • I tried a lot of things from other similar questions before I got here, the problem was the export of the dependencies, didn't know that the libraries don't have to export that things. Thank you, you saved my day! :) Gracias broder, te pasaste! – Alejandro Cumpa Jan 30 '14 at 17:01
  • It would be great to specify how to import the file in in the first place - when I click on "import" I don't have the option to import a jar. – c.fogelklou Aug 07 '14 at 03:31
7

If you are using Gradle, then you have a problem with the latest version of the compatibility library.

If you have the following in your build.gradle file with a '+' at the end:

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

then it may be grabbing a later version of the library than you want.

Changing the dependency to:

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

may fix your problem.

ZenBalance
  • 10,087
  • 14
  • 44
  • 44
6

Could you please try

android:theme="Theme.AppCompat.Light.DarkActionBar"

instead of

android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
Alex
  • 323
  • 2
  • 8
0

In your app dependencies file check if you have the dependency

compile 'com.android.support:appcompatv[anything here]

or

implement 'com.android.support:appcompat[anything here]

delete or comment them out, click on the "lightbulb" for auto-suggestions and choose add a library dependency. clicking on the autofillbulb for appcompat

Scroll the options for the first version of appcompat. The library will be added below the list of dependencies. Rebuild the app or invalidate caches and restart

In one case this has not worked and going to the folder containing the project, deleting the .gradle file and restarting Android Studio has worked. Got from Sneh Pandya's answer in https://reformatcode.com/code/android/error-while-gradle-sync

simiyu
  • 21
  • 3
0
  1. Go to your project directory (or to Project View)
  2. Find and open .idea directory
  3. Remove caches and libraries directories <-- this is essential
  4. Invalidate Caches / Restart