0
votes

I opened an existing project that work fine in Android Studio 2.1 Beta 2 and I have some errors when I run the project.

The style fields are:

<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>

And in the AndroidManifest.xml I have the reference for the theme like this:

 <application
  android:theme="@style/AppTheme" >

The errors are:

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'.

I tried several methods to solve this errors but without success. Please help me someone.

2

2 Answers

0
votes

The styles actually are coming from the AppCompat support library, which I assume are in your gradle dependencies.

Try changing the theme style declarations to

<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>

Also when dealing with studio upgrades:

  • Run > gradle > run with the task clean
  • File > Invalidate Caches/Restart -> Invalidate Cached and Restart
  • Make the project

It will throw out ALL old builds and artifacts and do a clean build instead of incremental. Sometimes resources get out of sync and this solves it.

0
votes

I found the solution for my errors. I had added the correct dependencies for android-support-v7-appcompat in the ProjectStructure->Modules->MyProjectName ->add dependencies. Work fine now.