我正在尝试实现谷歌几天前发布的新的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在加载,而不是资源。


当前回答

这个公认的解决方案曾经对我有用,但现在不是了。我必须在一个新的工作空间中重新创建一个相同类型的hello-world(!),对其进行编译,然后复制所有目录,包括.hg和.hgignore。 Hg差异显示:

-        android:targetSdkVersion="19" />
+        android:targetSdkVersion="21" />

Binary file libs/android-support-v4.jar has changed

看起来Eclipse想要为API 21编译,而不能使用API 19做任何事情。黑暗。

其他回答

这个公认的解决方案曾经对我有用,但现在不是了。我必须在一个新的工作空间中重新创建一个相同类型的hello-world(!),对其进行编译,然后复制所有目录,包括.hg和.hgignore。 Hg差异显示:

-        android:targetSdkVersion="19" />
+        android:targetSdkVersion="21" />

Binary file libs/android-support-v4.jar has changed

看起来Eclipse想要为API 21编译,而不能使用API 19做任何事情。黑暗。

我犯了一个非常愚蠢的错误。当我每次都得到相同的错误时,我不知道哪里出了问题。然后我突然意识到,一旦我关掉了我工作空间里的所有项目,那就是所有问题开始的时间。所以只要检查你的“appcompat_v7”是否没有关闭。如果是,则双击打开项目,然后清理并重新构建项目。在我的例子中,错误已经消失了。编码快乐!

我也遇到过同样的问题,浪费了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.

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

工作原理:

<style name="MyApp" parent="Theme.AppCompat.Light">
</style>
<style name="MyApp" parent="@style/Theme.AppCompat.Light">
</style>
<style name="Theme.AppCompat.Light.MyApp">
</style>

你需要参考$ANDROID_SDK/extras/android/support/v7/appcompat