我正在尝试实现谷歌几天前发布的新的ActionBar支持库。在过去,我已经成功地实现了ActionBarSherlock没有任何问题使用相同的方法在谷歌开发人员的支持库设置页面上列出-使用关于如何包括资源的指南(这是类似于ActionBarSherlock是如何做到的)。我把这个库项目作为库加载到我自己的项目中。

我能看出图书馆的资料还不错。当,而不是在我的MainActivity.java上扩展活动,我把它改为扩展ActionBarActivity(根据谷歌的指令),没有发生错误-它正确地导入。

我甚至尝试绕过style.xml文件,添加@style/Theme.AppCompat。光直接在AndroidManifest.xml的<应用>和<活动>与android:theme="@style/ThemeAppCompat。所有的尝试都会导致同样的错误。

现在的问题是我不能让它改变主题,更不用说在不抛出错误的情况下构建了。下面是我收到的错误,后面是我更改为使用新主题的style.xml文件。

我有一定的Android应用程序工作经验,正在运行Eclipse的最新版本的支持库和SDK编译API 18 (Android 4.3)。

生成时收到的错误

获取父项的错误:没有找到匹配给定名称的资源'@style/Theme.AppCompat.Light'。styles.xml /ActBarTest/res/values line 3 Android AAPT Problem

style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.ProsoftStudio.ACTest" parent="@style/Theme.AppCompat.Light">
    </style>
</resources>

有什么建议吗?这从来不是ActionBarSherlock的问题。我想使用这个新的支持库。看起来像是.jar在加载,而不是资源。


当前回答

我也遇到过同样的问题,浪费了4-5个小时来解决。我的问题用;

From SDK manager delete packages "Android Support Library" and " Android Support Repository". Reinstall "Android Support Library" and " Android Support Repository" Remove "android-support-v7-appcompat" or "appcompat_v7 what else you have in your project. Import android-support-v7-appcompat from "adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat" Select your project and from file choose properties and find Java Build Path and then from "Project" tab delete what else there and then Add. and you must see "android-support-v7-appcompat" , select and add it to Project tab. Check your project.properties file below your Project files, you will see like this; target=android-21 android.library.reference.1=../android-support-v7-appcompat then check AndroidManifest.xml file if target is 21 or what else you choosed. Also check for library reference same as your library that choosed before.

希望你能找到你的解决方案。

其他回答

这有点晚了,但这里是我如何在AndroidStudio完成它!

右击应用程序去属性

转到依赖项,单击“+”号并选择库依赖项 选择appcompat-v7

由于Android Studio 1.0.1中的导入对话框不同,我无法让Svyatoslav Lobachs版本工作。

相反,我在SDK管理器中下载了“Android支持资源库”。然后补充说

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

build.gradle。为我工作。

如果你已经添加了appCompat库,并从SDK位置给出了适当的appCompat引用,请尝试“invalidate cache /Restart”。 你可以在Android Studio的“文件”菜单中找到它。

遵循@rcdmk的步骤。 在你的项目中删除android support v4.jar它与在appcompat中发现的新更新版本冲突。

忘记一切。只需使用从Android Studio下载的appcompat库即可。它拥有所有缺失的定义。无论您是否在Eclipse中使用。