【问题标题】:error parsing:unbound prefix exception错误解析:未绑定前缀异常
【发布时间】:2014-01-16 06:57:07
【问题描述】:

此代码显示未绑定异常,我尝试了所有组合.. 无法解决!!

    <com.google.android.maps:MapView
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"       
     android.apikey="AIzaSyDIqLvjKi_VM7nT1DUSTzIeKDTuzPGFqrQ"/>

整个代码是:

    <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >  
     <com.google.android.maps:MapView
      android:id="@+id/map1"    
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"    
      android:apikey="AIzaSyDIqLvjKi_VM7nT1DUSTzIeKDTuzPGFqrQ"/>
     </RelativeLayout>

【问题讨论】:

  • 显示完整的 xml 布局。为什么MapView中的api键是?
  • 还发布您的 Java 代码和清单。怀疑更多的错误

标签: android google-maps exception


【解决方案1】:

你需要这个

 xmlns:android="http://schemas.android.com/apk/res/android"

在 xml 的根元素中

    <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >  
     <com.google.android.maps.MapView // :MapView is .MapView
      android:id="@+id/map1"    
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"/>    
     </RelativeLayout>

还有

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="api key"/>
// android.apikey

必须在清单文件的应用标签中

你可以找到一个例子

Android - android.view.InflateException: Binary XML file line #8: Error inflating class fragment

参考

https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

【讨论】:

    【解决方案2】:

    您添加的 Mapview &lt;com.google.android.maps:MapView 定义错误。 :MapView 之前,这是错误的。您必须将: 替换为.。 如下所示:

    <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="wrap_content"
    /> 
    

    并将 API 密钥添加到清单中的应用程序标记中,如下所示:

    <meta-data
      android:name="com.google.android.maps.v2.API_KEY"
       android:value="your api key"/>
    

    【讨论】:

      【解决方案3】:

      android.apikey 替换为 android:apikey

      希望对你有帮助..

      【讨论】:

        猜你喜欢
        • 2012-11-02
        • 1970-01-01
        • 2015-05-09
        • 1970-01-01
        • 1970-01-01
        • 2015-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多