【问题标题】:Android maps:Failed to find style 'mapViewStyle' in current themeAndroid 地图:在当前主题中找不到样式“mapViewStyle”
【发布时间】:2012-03-16 09:35:18
【问题描述】:

我正在尝试在我的应用程序中使用地图,但出现此错误, 在当前主题中找不到样式“mapViewStyle”

我已经正确生成了密钥,并尝试了其他地方针对同一问题提供的所有解决方案。

1.my target api and the one mentioned in the manifest file are the same.
2.There is no import.R in my project
3.I have cleaned my project.
4.Uses-library element is a child of the application.

这是我的 xml 文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        android:apiKey="*****************" 
        android:enabled="true"
        />

</LinearLayout>

这是我对应的java文件

包com.epidemicator.prototype;

import android.os.Bundle;
import com.google.android.maps.MapActivity;

public class Mapacti extends MapActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mapview);
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

请帮帮我... 谢谢。

【问题讨论】:

标签: android xml google-maps


【解决方案1】:

我的回答可能比较晚,但我希望它能解决实际原因,并确保它对那些将来要搜索相同问题的人有所帮助。

这类错误,

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 

上面列表中的任何东西都可以,

最终的原因是,

我们为layout 选择了不可用的Theme

这可能是由于以下原因,

  1. 所选的themethemes.xml 文件中不可用。
  2. 选中的theme属于高版本sdk,但我们当前的目标sdk是低版本。

这个问题大多发生,

  1. 当您复制整个layout 文件并尝试在您的project 中实现它时。 一种。您可能忘记复制themes.xml 文件 湾。您可能有较低的target sdk,原来的layout 是用较高的target sdk 创建的。

这个问题的解决方案是,

(打开查看Graphical Layout View中的layout文件,并查看右上角。 你的themes layout 已被选中。)

  1. 所以点击下拉列表theme选择并根据你的项目themestargeted sdk themes选择可用的themes(或)
  2. 如果themecustom 之一,如果您需要它,则将themes.xml 文件从您复制layout xml 文件的源复制到您的项目。 (或)
  3. 如果themesdk可用theme,如果你需要它,然后根据你选择的theme更改你的target

希望 - 这可能对某人有所帮助。

【讨论】:

    【解决方案2】:

    我想我会添加这个小花絮。我收到上面的错误#4。我花了很长时间才意识到我为Preferences 制作的主题会自动应用于我已经制作的每个布局文件。如上所述选择不同的解决了我的问题。我不知道为什么 Android Studio 会自动将它应用到我的所有其他布局中,但我希望它不会。

    我仍然不知道为什么我制作的主题会破坏一切,因为它只是将背景颜色应用于我的 Preferences 页面,但希望有一天我会这样做。

    【讨论】:

      猜你喜欢
      • 2012-01-20
      • 2011-11-14
      • 2012-05-25
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-15
      • 2018-12-05
      相关资源
      最近更新 更多