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

心不动则不痛 提交于 2020-01-21 10:56:26

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10651456/google-maps-in-android-failed-to-find-style-mapviewstyle-in-current-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!