Android Google地图应用崩溃

时间:2013-11-07 02:42:39

标签: android google-maps

我有一个使用谷歌地图的应用程序。以前,它工作正常,但昨晚我在sdk管理器中更新了一些东西,这样做导致我的地图活动崩溃我的应用程序。经过多次尝试修复它,我更新到最新版本的eclipse,重新下载了google play服务,并生成了一个新的API密钥。但是,我的应用程序在我的Android设备上运行时仍然崩溃,我无法弄清楚为什么。请帮忙。下面是我的清单文件(我使用新的API密钥更新)以及包含错误的日志。任何帮助都会非常感激。谢谢。 清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.workoutprofile"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="5"
        android:targetSdkVersion="17" />

    <permission
        android:name="com.example.workoutprofile.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.example.workoutprofile.permission.MAPS_RECEIVE"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBp5Var-gdHHN2d6ENeHMW2kPSlGjLywFU"/>

        <activity
            android:name="com.example.workoutprofile.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="Map"></activity>
        <activity android:name="Record"></activity>
        <activity android:name="Setup"></activity>
        <activity android:name="Bluetooth"></activity>
        <activity android:name="Chart"></activity>
        <activity android:name="History"></activity>
        <activity android:name="org.achartengine.GraphicalActivity"></activity>
        <activity android:name="Test"></activity>
        <activity android:name="MapTest"></activity>
    </application>


</manifest>

logcat的:

11-06 20:35:57.708: D/dalvikvm(12454): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
11-06 20:35:57.708: W/dalvikvm(12454): VFY: unable to resolve instance field 32
11-06 20:35:57.708: D/dalvikvm(12454): VFY: replacing opcode 0x52 at 0x0012
11-06 20:35:57.708: D/dalvikvm(12454): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
11-06 20:35:57.715: D/AndroidRuntime(12454): Shutting down VM
11-06 20:35:57.715: W/dalvikvm(12454): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
11-06 20:35:57.723: E/AndroidRuntime(12454): FATAL EXCEPTION: main
11-06 20:35:57.723: E/AndroidRuntime(12454): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.workoutprofile/com.example.workoutprofile.Map}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1722)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.ActivityThread.access$1500(ActivityThread.java:124)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.os.Looper.loop(Looper.java:130)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.ActivityThread.main(ActivityThread.java:3821)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at java.lang.reflect.Method.invokeNative(Native Method)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at java.lang.reflect.Method.invoke(Method.java:507)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at dalvik.system.NativeStart.main(Native Method)
11-06 20:35:57.723: E/AndroidRuntime(12454): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:253)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.Activity.setContentView(Activity.java:1716)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.example.workoutprofile.Map.onCreate(Map.java:64)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
11-06 20:35:57.723: E/AndroidRuntime(12454):    ... 11 more
11-06 20:35:57.723: E/AndroidRuntime(12454): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.dynamic.a.a(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
11-06 20:35:57.723: E/AndroidRuntime(12454):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
11-06 20:35:57.723: E/AndroidRuntime(12454):    ... 20 more

地图布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin" >

    <TextView
        android:id="@+id/mapHeader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="MAP"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="480dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:id="@+id/buttonRouteStart"
        android:layout_width="125dp"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/buttonScreenshot"
        android:layout_alignBottom="@+id/buttonScreenshot"
        android:layout_alignRight="@+id/map"
        android:text="Route" />

    <Button
        android:id="@+id/buttonScreenshot"
        android:layout_width="125dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/mapHeader"
        android:layout_alignLeft="@+id/map"
        android:text="Save" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:2)

您提供的api密钥错误。密钥不包含“ - ”。转到云控制台。在Platform中选择android。选择直接从Android访问“API”提供包名称和SHA1指纹。复制粘贴生成的API密钥。另外,请确保已启用API和身份验证下的“Google Maps Android API v2”。

编辑:Google已经更新了库,因此出现了问题。您可以找到问题的解决方案here