Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps in Android: Failed to find style 'mapViewStyle' in current theme

Sorry guys, another one about this topic. I have read ALL the postings about it so far, but so far none of the answers worked out for me. I have spent hours on trying to fix that now and before starting to pull my hairs out, I'd like to give it another try here.

I'm getting the above error message in Eclipse when switching between XML layout and graphical 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

Here is my layout XML file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<!-- Screen Design for the MAP Tab -->
<TextView
    android:id="@+id/vvm_offline"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="15dip"
    android:text="You have to be online to display the map."
    android:textSize="18dip" />

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:apiKey="xxx"
    android:clickable="true"
    android:state_enabled="true" />

<LinearLayout
    android:id="@+id/zoom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</LinearLayout>

In my AndroidManifest.xml, everything seems to be as it should be according to the other tips I've found:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.myapp"
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:label="@string/app_name" >
    <uses-library
        android:name="com.google.android.maps"
        android:required="true" />

    <activity
        android:name=".myappActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
    (etc.)

    <activity
        android:name=".ViewMapActivity"
        android:label="View Map" >
    </activity>
    (etc.)

By the way, it makes no difference whether I have defined the 'theme' in android:theme or not.

Any ideas how to fix this error? I can compile and run the app, but get a NullPointerException when the view is created.

like image 415
richey Avatar asked May 18 '12 11:05

richey


1 Answers

This happened to me too.. go into res>values>styles.xml

remove the previous theme line and put this one

<style name="AppBaseTheme" parent="android:Theme.Light">

The eclipse during the project creation asks to define a theme for the application. You might have selected any Holo theme. This theme doesn't support MapView which is showing the error.

like image 116
Rohan Kandwal Avatar answered Nov 03 '22 01:11

Rohan Kandwal