2013-08-21 44 views
14

如何使用正确的Android支持库,因为我在清单文件中有这样的错误:
Theme.AppCompat.Light.DarkActionBar - 无资源发现

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 

我的朋友没有这种以前实现我另一台计算机上,现在我必须单独做这件事。请帮我:)

我使用ADT

我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

在eclipse中导入AppCompat库项目(支持lib v7)。 看到这个 - http://developer.android.com/tools/support-library/index.html – Varun

+0

我做到了这一点,但问题还没有解决 – Jerry

+0

你是否已经将appcompat项目添加为应用程序中的库项目? – Varun

回答

16

在 “Android的支持-V7-程序兼容性” 项目:

  • 删除“机器人-support-v7-appcompat“。
  • 再次导入并勾选“复制到工作区”
  • 在属性 - > Android的 - >在项目建设目标,取消的Android 2.2和Android的检查4.1.2
  • 在Java构建路径,取消,如果您有任何。罐子库,并取消的依赖性

在另一方面,使用“Android的支持-V7-程序兼容性”的项目:

  • 在属性 - > Android的添加库,但取消“IsLibrary “。
  • 在Android - >项目构建tarjet检查Android 4.0。
  • 在“Java构建路径” - >在线订单和出口 - >未选中该.jar库
  • 最后做了“项目 - >清除”这两个项目
+0

我试过了在我来到这里之前,很多其他类似问题的事情,问题是依赖项的导出,不知道库不必导出那些东西。谢谢,你救了我的一天! :)格拉西亚斯broder,te pasaste! – Aiapaec

+0

这将是很好的指定如何导入文件在第一个地方 - 当我点击“导入”我没有选择导入一个罐子。 –

7

如果使用的是摇篮,那么你有最新版本的兼容性库的问题。

如果你在你的build.gradle文件与'+'在末尾以下内容:

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

则可以抓住库的版本比你想要的。

改变依赖于:

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

可以解决您的问题。

5

可否请您尝试

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

,而不是

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

它真的有用吗? –

+1

这是行不通的 –

0

在你的应用程序依赖文件检查,如果你有依赖

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

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

删除或注释掉它们,单击“灯泡”以获得自动建议并选择添加库依赖项。 clicking on the autofillbulb for appcompat

滚动第一个版本的appcompat的选项。该库将被添加到依赖项列表下方。重建应用程序或使缓存无效并重新启动

在一种情况下,该功能无法正常工作并进入包含该项目的文件夹,删除.gradle文件并重新启动Android Studio已运行。从Sneh Pandya的回答中获得https://reformatcode.com/code/android/error-while-gradle-sync

相关问题