Failed to find style 'mapViewStyle' in current theme

ekjyot picture ekjyot · Sep 10, 2011 · Viewed 43.2k times · Source

I am making an app which uses google maps. But in my xml I get th error "Failed to find style 'mapViewStyle' in current theme." Instead I have given onternet permission and used the google maps library inside the application tag.

Can anybody help me over this.

Thanks a lot

following is my xml file...

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
  <com.google.android.maps.MapView
    android:id="@+id/mapview1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="0ACHOtlugQlOP_-siR3LLyIBjv1SwpKWimIY8jw" />
</Relativelayout>

Answer

Kartihkraj Duraisamy picture Kartihkraj Duraisamy · Oct 25, 2012

My answer may be a late one, but i hope that it'll deals with the actual reason and sure it could be helpful for those who are going to search about the same problem in future.

This type of errors,

1. Android Google Maps Failed to find style 'mapViewStyle' in current theme
2. Failed to find style 'imageButtonStyle' in current theme 
3. Failed to find style 'editTextStyle' in current theme 
4. Failed to find style 'textViewStyle' in current theme 

Anything from the above list it may be,

The ultimate reason is ,

We have selected the unavailable Theme for the layout.

This may cause because of,

  1. The selected theme is not available in themes.xml file.
  2. The selected theme is belongs to higher version sdk, but our current target sdk is lower one.

This problem mostly happens,

  1. when you copy the whole layout file and try to implement it in your project. a. Your may forgot to copy themes.xml file b. You may have lower target sdk, the original layout created with higher target sdk.

The Solutions for this problem are,

(Open and View the layout file in the Graphical Layout View, and look at the top Right corner. There your themes for the layout have been selected.)

  1. So click the dropdown list for theme selection and choose the available themes according to your project themes and targeted sdk themes. (OR)
  2. If the theme is a custom one , if you are required it , then copy the themes.xml file to your project from the source where you copied the layout xml file. (OR)
  3. If the theme is sdk avail theme, if you are required it , then change your target according to your selected theme.

Hope,This might be helpful for somebody.