Google Maps API密钥错误:应用的AndroidManifest.xml中的元数据标记没有正确的值

时间:2015-10-20 07:47:36

标签: maps key

我正在尝试使用我的Android应用程序的片段显示googlemaps。 但是我得到了很多错误。

这是我看到的一个错误:

  

应用的AndroidManifest.xml中的元数据标记没有正确的值....

我的API密钥可能有错吗?我使用SHA1指纹创建它,但大多数关键教程使用MD5指纹......有没有办法测试我的密钥?

这是我的活动主要xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    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"
    tools:context="com.Dennis.googlemaps.MainActivity" >

    <TextView
        android:id="@+id/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />


    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_below="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

这是我的清单:

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

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

           <permission
        android:name="com.Dennis.googlemaps.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.Dennis.googlemaps.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-feature
          android:glEsVersion="0x00020000"
          android:required="true" />

    <application
        android:allowBackup="true"
        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="AIzaSyBxepoklPmNhk2CK-4o5BPXDbLKTJ8hBXg" />

        <activity
            android:name=".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>
    </application>

</manifest>

这是logcat:

10-20 09:37:00.399: E/Trace(12409): error opening trace file: No such file or directory (2)
10-20 09:37:00.479: W/dalvikvm(12409): VFY: unable to resolve virtual method 228: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
10-20 09:37:00.479: W/dalvikvm(12409): VFY: unable to resolve instance field 17
10-20 09:37:00.490: E/dalvikvm(12409): Could not find class 'android.os.UserManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzah
10-20 09:37:00.490: W/dalvikvm(12409): VFY: unable to resolve check-cast 261 (Landroid/os/UserManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
10-20 09:37:00.490: E/dalvikvm(12409): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzb
10-20 09:37:00.490: W/dalvikvm(12409): VFY: unable to resolve check-cast 25 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
10-20 09:37:00.490: W/dalvikvm(12409): VFY: unable to resolve virtual method 482: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
10-20 09:37:00.490: W/dalvikvm(12409): threadid=1: thread exiting with uncaught exception (group=0x40c54468)
10-20 09:37:00.500: E/AndroidRuntime(12409): FATAL EXCEPTION: main
10-20 09:37:00.500: E/AndroidRuntime(12409): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Dennis.googlemaps/com.Dennis.googlemaps.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.ActivityThread.access$600(ActivityThread.java:151)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.os.Looper.loop(Looper.java:155)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.ActivityThread.main(ActivityThread.java:5454)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at java.lang.reflect.Method.invokeNative(Native Method)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at java.lang.reflect.Method.invoke(Method.java:511)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at dalvik.system.NativeStart.main(Native Method)
10-20 09:37:00.500: E/AndroidRuntime(12409): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class fragment
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:363)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.Activity.setContentView(Activity.java:1912)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.Dennis.googlemaps.MainActivity.onCreate(MainActivity.java:13)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.Activity.performCreate(Activity.java:5066)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
10-20 09:37:00.500: E/AndroidRuntime(12409):    ... 11 more
10-20 09:37:00.500: E/AndroidRuntime(12409): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 8115000 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" />
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.common.GooglePlayServicesUtil.zzad(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.maps.internal.zzy.zzaH(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.maps.internal.zzy.zzaG(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.maps.MapFragment$zzb.zzxL(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.maps.MapFragment$zzb.zza(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.dynamic.zza.zza(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.dynamic.zza.onInflate(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.app.Activity.onCreateView(Activity.java:4721)
10-20 09:37:00.500: E/AndroidRuntime(12409):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
10-20 09:37:00.500: E/AndroidRuntime(12409):    ... 21 more
10-20 09:42:00.540: D/Process(12409): killProcess, pid=12409
10-20 09:42:00.550: D/Process(12409): dalvik.system.VMStack.getThreadStackTrace(Native Method)
10-20 09:42:00.550: D/Process(12409): java.lang.Thread.getStackTrace(Thread.java:599)
10-20 09:42:00.550: D/Process(12409): android.os.Process.killProcess(Process.java:944)
10-20 09:42:00.550: D/Process(12409): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
10-20 09:42:00.550: D/Process(12409): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
10-20 09:42:00.550: D/Process(12409): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
10-20 09:42:00.550: D/Process(12409): dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案