Android Studio 0.4.2和Google Map api v2 - 与Google服务器联系时出错

时间:2014-01-14 00:06:09

标签: android google-maps android-studio google-play-services

我花了几个小时来创建一个AS 0.4.2的新项目,结果再次是一个空白的地图,有三个错误:

E/Google Maps Android API﹕ Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
E/Google Maps Android API﹕ Ensure that the following correspond to what is in the API Console: Package Name: com.demomap, API Key: AIzaSyBiYMhCKkRR-rqScAQgbetmVCCBZusgvcE, Certificate Fingerprint: DC37F5B58C2526B6FF8A6A72F8AB7A81D90F0779
E/GetJar SDK [com.zeptolab.ctr.ads]﹕ Usage: UsageRollupDatabase: collectAppSessionEvent() Failed to find or create a reporting window for an event with timestamp 1389656136587, giving up...
E/GetJar SDK [com.zeptolab.ctr.ads]﹕ Usage: UsageRollupDatabase: collectAppSessionEvent() Failed to find or create a reporting window for an event with timestamp 1389656136845, giving up...
E/Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors)

这是我在build.gradle中更改的内容:

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile 'com.google.android.gms:play-services:4.0.30'
}

这是我的清单:

<?xml version="1.0" encoding="utf-8"?>

<permission
    android:name="com.demomap.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="com.example.osman.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" >

    <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>

    <activity android:name=".BasicMapActivity" android:label="@string/app_name" />
    <activity android:name=".LegalInfoActivity" android:label="@string/app_name" />

    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBiYMhCKkRR-rqScAQgbetmVCCBZusgvcE" />
</application>

我的应用程序本周工作正常,现在我不知道出了什么问题。试图多次更改密钥仍然没有 - 只有空白地图和该消息。 如果我从清单中删除该行:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

应用程序崩溃了:

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

有没有人处理过类似的问题?

0 个答案:

没有答案