我打开了一个在AndroidStudio2.1Beta 2中运行良好的现有项目,运行该项目时出现了一些错误。
样式字段是:
<style name="AppBaseTheme" parent="@android:style/Theme.AppCompat.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="AppBaseTheme" parent="@android:style/Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>
<style name="AppBaseTheme" parent="@android:style/Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>在AndroidManifest.xml中,我引用了这样的主题:
<application
android:theme="@style/AppTheme" >这些错误是:
错误:(7,-1) android-apt编译器: mobile C:\mobile\trunk\res\values\styles.xml:7: error: Error检索项的父级:没有找到与给定名称'@android:style/Theme.AppCompat.Light‘匹配的资源。 错误:(7,-1) android-apt编译器: mobile:\mobile\躯干\res\values v11\styes.xml:7:错误:错误检索项的父级:没有找到与给定名称'@style/Theme.AppCompat.Light‘匹配的资源。 错误:(8,-1) android-apt编译器: mobile:\mobile\躯干\res\values v14\styes.xml:8:错误:错误检索项目的父级:没有找到与给定名称'@style/Theme.AppCompat.Light‘匹配的资源。
我尝试了几种方法来解决这个错误,但没有成功。请帮帮我。
发布于 2016-05-16 12:19:33
我为我的错误找到了解决办法。我在ProjectStructure->Modules->MyProjectName ->add依赖项中添加了android-support-v7-appcompat的正确依赖项。现在好好工作。
发布于 2016-05-14 16:08:13
这些样式实际上来自于AppCompat支持库,我假设它在您的gradle依赖项中。
尝试将主题样式声明更改为
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</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="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>此外,在处理演播室升级时:
clean运行> gradle >运行它将丢弃所有的旧构建和工件,并做一个干净的构建,而不是增量。有时资源不同步,这就解决了问题。
https://stackoverflow.com/questions/37227771
复制相似问题