Theme.AppCompat.Light.DarkActionBar - No resource found

邮差的信 提交于 2019-12-17 07:29:34

问题


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>

回答1:


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



回答2:


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.




回答3:


Could you please try

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

instead of

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



回答4:


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




回答5:


  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


来源:https://stackoverflow.com/questions/18364682/theme-appcompat-light-darkactionbar-no-resource-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!