【问题标题】:Android google maps v2 unknown errorAndroid google maps v2 未知错误
【发布时间】:2014-02-13 15:39:05
【问题描述】:

我尝试在他的开发者页面上制作这个示例

https://developers.google.com/maps/documentation/android/start?hl=tr#obtain_a_google_maps_api_key

这是我的 java 代码:

package com.example.mapdemo;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

和xml代码:

   <?xml version="1.0" encoding="utf-8"?>
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:name="com.google.android.gms.maps.MapFragment"/>

但如果我尝试在 REAL DEVICE 上执行此操作,Log cat 会说:

  02-13 17:28:59.327: W/dalvikvm(12793): threadid=1: thread exiting with uncaught exception (group=0x410c02a0)
    02-13 17:28:59.327: E/AndroidRuntime(12793): FATAL EXCEPTION: main
    02-13 17:28:59.327: E/AndroidRuntime(12793): java.lang.RuntimeException: 
Unable to start activity
ComponentInfo{com.restroomgames.urfarehberi/com.restroomgames.urfarehberi.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment

还有:

 02-13 17:28:59.327: E/AndroidRuntime(12793): Caused by: 
android.app.Fragment$InstantiationException: Unable to instantiate fragment 
com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an
 empty constructor that is public

还有:

    02-13 17:28:59.327: E/AndroidRuntime(12793): Caused by:
 java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment

这个视频帮助了我:https://www.youtube.com/watch?v=fitjMdZ8jqM 我认为问题是 Debug.keystore 或 google play 服务,因为我更改了它们,问题就消失了。

我也在我的网页上写了解决方案:

http://restroomgames.com/blog.php?ID=27

【问题讨论】:

    标签: android api google-maps android-fragments api-key


    【解决方案1】:

    您似乎使用了错误的充气模式。

    java.lang.RuntimeException: Unable to start activity 
    ComponentInfo{com.restroomgames.urfarehberi/com.restroomgames.urfarehberi.MainActivity}:
    android.view.InflateException: Binary XML file line #2: Error inflating class fragmen
    

    看看这个解决方案: https://stackoverflow.com/a/15137231/2523005

    【讨论】:

    • 也许你会是对的,但我无法解决它。我下载了一些教程并导入了它们。还有一些错误:[2014-02-13 21:50:39 - GoogleMapsV2] 无法解析目标 'android-12' [2014-02-13 21:50:40 - GoogleMapsV2] 无法解析目标'android- 12' [2014-02-13 22:05:52 - actionbarsherlock] 无法解析目标 'android-14' [2014-02-13 22:05:52 - google-play-services_lib] 无法解析目标 'android- 8' [2014-02-13 22:06:14 - google-play-services_lib] 无法解析目标 'android-8' [2014-02-13 22:06:15 - actionbarsherlock] 无法解析目标'android- 14'
    • 你只下载了教程?你用的是什么教程?你有没有安装 android sdk?
    【解决方案2】:

    您无法在模拟器中测试 Google 地图。它没有 Google Play 服务。

    【讨论】:

    • 我用的是真机
    • 你能提供你的清单文件吗?或至少部分与 Google Play 服务权限相关。
    猜你喜欢
    • 1970-01-01
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多