Android-apt-compiler :[] error:Error retrieving parent for item: No resource found that matches the given name ''
Android-apt-compiler :[] error:Error retrieving parent for item: No resource found that matches the given name ''
我打开了一个在 Android Studio 2.1 Beta 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" >
错误是:
Error:(7, -1) android-apt-compiler: [mobile]
C:\mobile\trunk\res\values\styles.xml:7: error: Error retrieving
parent for item: No resource found that matches the given name
'@android:style/Theme.AppCompat.Light'.
Error:(7, -1) android-apt-compiler: [mobile] C:\mobile\trunk\res\values-v11\styles.xml:7: error: Error retrieving
parent for item: No resource found that matches the given name
'@style/Theme.AppCompat.Light'.
Error:(8, -1) android-apt-compiler: [mobile] C:\mobile\trunk\res\values-v14\styles.xml:8: error: Error retrieving
parent for item: No resource found that matches the given name
'@style/Theme.AppCompat.Light'.
我尝试了几种方法来解决这个错误,但都没有成功。请有人帮助我。
样式实际上来自 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>
另外在处理工作室升级时:
- 运行 > gradle > 运行 与任务
clean
- 文件 > 无效 Caches/Restart -> 使缓存无效并重新启动
- 制作项目
它将丢弃所有旧的构建和工件并进行干净构建而不是增量构建。有时资源会不同步,这可以解决问题。
我找到了错误的解决方案。
我在 ProjectStructure->Modules->MyProjectName ->add dependencies 中为 android-support-v7-appcompat 添加了正确的依赖项。
现在工作正常。
我打开了一个在 Android Studio 2.1 Beta 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" >
错误是:
Error:(7, -1) android-apt-compiler: [mobile] C:\mobile\trunk\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light'.
Error:(7, -1) android-apt-compiler: [mobile] C:\mobile\trunk\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Light'.
Error:(8, -1) android-apt-compiler: [mobile] C:\mobile\trunk\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Light'.
我尝试了几种方法来解决这个错误,但都没有成功。请有人帮助我。
样式实际上来自 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>
另外在处理工作室升级时:
- 运行 > gradle > 运行 与任务
clean
- 文件 > 无效 Caches/Restart -> 使缓存无效并重新启动
- 制作项目
它将丢弃所有旧的构建和工件并进行干净构建而不是增量构建。有时资源会不同步,这可以解决问题。
我找到了错误的解决方案。 我在 ProjectStructure->Modules->MyProjectName ->add dependencies 中为 android-support-v7-appcompat 添加了正确的依赖项。 现在工作正常。