[android] Missing styles. Is the correct theme chosen for this layout?

Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed to find style mapViewStyle in current theme.

I tried every solutions available to solve this problem but nothing seems to work. I have included library in the manifest file. I even created style is styles.xml, I have chosen Google Apis build target as well.

Can somebody please give me a solution?

here is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/AppTheme"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >


 <com.google.android.maps.MapView
     android:id="@+id/themap"
     style="@style/mapViewStyle"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:apiKey="here i have my key"
     android:clickable="true"
     android:enabled="true" />

  </RelativeLayout>   

Here is my manifest snippet:

  <uses-library android:name="com.google.android.maps" />

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Second" />

    <activity android:name=".Third"  android:theme="@android:style/Theme.Black"/>
  </application>

here is my style.xml file

<resources>
    <style name="mapViewStyle" parent="@android:style/Theme.Black">
    </style>
</resources>

This question is related to android

The answer is


In my case the problem occurred while the default setting for Android Version in the Designer was set to 'Preview N'. Changed Android Version to '23' and the error notification went away.
Edit
And don't forget to uncheck 'Automatically Pick Best'.


Change your App theme to AppCombat.. enter image description here


If you still have the problem after trying all the solutions above, please try modify the API Level as shown below. Incorrect API Level may also cause the problem.

enter image description here


This is because you select not a theme of your project. Try to do next:

enter image description here


Try switching the theme in the design view to one of the options in "Manifest Themes". I'm guessing this is Because you are inheriting the theme from the manifest to support multiple api levels. It worked for me anyway.


If we are creating too many projects using Android Studio sometime Rendering issue comes. Even creating a blank activity we receive such rendering error. Please shut down and restart Android studio. In case the issue persists you can Android Studio Cache Invalidation and Restart

Hope this helps. It works similar fashion as rule of thumb, in case all looks good and still error persists a restart of application usually resolves the issue.


I meet the same problem.Select theme to another one in preview can solve problem temporary.Like the image

Finally,I found out that there are AppTheme and AppBaseTheme in my styles.xml. And AppTheme has parent AppBaseTheme. The AppBaseTheme has parent of one system style.

And every layout file use the theme AppTheme. Just change AppTheme's parent to AppBaseTheme's parent. It solve the problem permanent.


I had the same problem and found it was the Theme dropdown at the top of the graphical layout editor. I changed from Holo to Theme and the layout displayed and error disappeared.


I solved it by changing "classpath" in "dependencies" in build.gradles.

Just change:

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0-alpha2'

or something like that to:

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

I had the same problem using Android Studio 1.5.1.

This was solved by using the Android SDK Manager and updating Android Support Library, as well as Local Maven repository for Support Libraries.

enter image description here

After updating the SDK and restarting Android Studio, the problem was rectified.

Hope this helps anyone who has the same problem after trying other suggestions.


This is very late but i like to share my experience this same issue. i face the same issue in Android studio i tried to some other solution that i found in internet but nothing works for me unless i REBUILD THE PROJECT and it solve my issue.

Hope this will works for you too.

Happy coding.


What I usually do is the following: a Gradle Clean, Rebuild and Sync all my Gradle files. After that I restart Android Studio, and I go to:

Select Theme -> Project Themes -> AppTheme

I got this error after overriding action bar style like this. Also i lost action bar in preview.

<style name="general_app_theme" parent="@style/Theme.AppCompat">
    <!-- for API level 11 -->
    <item name="android:actionBarStyle">@style/action_bar_style</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/action_bar_style</item>

</style>

<style name="action_bar_style" parent="@style/Widget.AppCompat.ActionBar">
    <!-- for API level 11 -->
    <item name="android:height">@dimen/action_bar_height</item>
    <item name="android:background">@color/action_bar_color</item>
    <item name="android:displayOptions">showTitle</item>

    <!-- Support library compatibility -->
    <item name="displayOptions">showTitle</item>
</style>

So, problem is overriding theme by my custom. this is the reason, why I've changed AppCompat (from "Project Themes") to general_app_theme (from "Manifest Themes"). Now I have no this error and action bar in preview come back.


I got the same problem with my customized theme that used Holo.Light as its parent. In grayed text Android Studio indicated that some attributes were missing. When I added these missing attributes as follows, the rendering problems went away -

    <item name="android:textEditSuggestionItemLayout"></item>
    <item name="android:textEditSuggestionContainerLayout"></item>
    <item name="android:textEditSuggestionHighlightStyle"></item>

Even though they introduced errors in my style's theme, they caused no problems in rendering the activity designs or building my app.


For Android Studio (or IntelliJ IDEA),

If everything looks OK in your project and you're still receiving the error in your layouts, try to 'Invalidate caches & restart'.

Enjoy a coffee while Android Studio is recreating caches & indexes.

how to invalidate cache & restart


Just need click button 'AppTheme', and choose 'Manifest Themes'. It works in most cases.


Most of the errors in XML happen due to the names you have given to the resources.

Images stored in the drawable folder need to be named in a proper manner. just check these things:

  1. Are there any duplicate files? if so remove the duplicates. (For example "image.jpg" and "image.png" are not allowed in the same time. It will not show any errors but sometimes it will show that R.java cannot be resolved)
  2. Do the filenames contains any uppercase letters? If so right click on that file->refactor->rename and rename it with all lowercase, no hyphens, and only a-z and 0-9 are allowed.

Just make sure of the above cases.


For me, it was occurring on menu.xml file as i was using android:Theme.Light as my theme, So what i did was -

  1. Added new Folder in res directory named values-v21.

  2. Added android:Theme.Material.Light as AppTheme in styles.xml.


With reference to the answer provided by @Benno: Instead of changing to a specific theme, you can simply choose 'DeviceDefault' from the theme menu. This should choose the theme most compatible with the emulated device.


You can simply remove this error through change "App theme" and select any theme such as light. This error will be removed.


It can be fixed by changing your theme in styles.xml from Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

to

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

and clean the project. It will surely help.