Google Maps API需要不同的密钥

时间:2016-04-21 06:46:00

标签: android google-maps google-maps-android-api-2

我正在使用适用于Android的Google Maps API,并且我使用正确的项目名称和SHA1值多次创建了我的凭据,但是我一直收到错误,其中应用程序由于某种原因需要不同的API密钥比我提供的那个,但我无法在任何地方找到这个API密钥,它不接受我给它的任何新密钥。以下是打开地图活动时的Android Studio日志。

04-21 02:34:02.400 3384-3384/project.topka.beacon11 I/GMPM: App measurement is starting up, version: 8487
04-21 02:34:02.400 3384-3384/project.topka.beacon11 I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
04-21 02:34:02.430 3384-3384/project.topka.beacon11 E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
04-21 02:34:02.430 3384-3384/project.topka.beacon11 E/GMPM: Scheduler not set. Not logging error/warn.
04-21 02:34:02.530 3384-3384/project.topka.beacon11 W/asset: Copying FileAsset 0xb91b2788 (zip:/data/data/project.topka.beacon11/files/instant-run/left/resources.ap_:/resources.arsc) to buffer size 502868 to make it aligned.
04-21 02:34:02.540 3384-3416/project.topka.beacon11 E/GMPM: Uploading is not possible. App measurement disabled
04-21 02:34:02.640 3384-3384/project.topka.beacon11 D/Atlas: Validating map...
04-21 02:34:02.680 3384-3384/project.topka.beacon11 D/FindExtension: FindExtension: before mHardwareRenderer.initialize, mSurface.isValid() = true
04-21 02:34:02.680 3384-3420/project.topka.beacon11 I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build:  ()
                                                                  OpenGL ES Shader Compiler Version: E031.25.03.04
                                                                  Build Date: 04/24/15 Fri
                                                                  Local Branch: 
                                                                  Remote Branch: 
                                                                  Local Patches: 
                                                                  Reconstruct Branch: 
04-21 02:34:06.750 3384-3384/project.topka.beacon11 V/IntroScreen: Starting update location service
04-21 02:34:06.840 3384-3384/project.topka.beacon11 D/FindExtension: FindExtension: before mHardwareRenderer.initialize, mSurface.isValid() = true
04-21 02:35:19.200 3384-3384/project.topka.beacon11 V/IntroScreen: Starting update location service
04-21 02:35:19.220 3384-3384/project.topka.beacon11 I/InputMethodManager: [startInputInner] EditorInfo { packageName=project.topka.beacon11, inputType=0x21, imeOptions=0x8004005, privateImeOptions=null }, windowGainingFocus=android.view.ViewRootImpl$W@c4c10d5, mServedView=android.widget.EditText{34240ea VFED..CL .F...... 24,336-516,404 #7f0d009d app:id/login_username}, mServedInputConnectionWrapper=android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper@31f91fdb
04-21 02:35:22.650 3384-3384/project.topka.beacon11 I/zzad: Making Creator dynamically
04-21 02:35:22.660 3384-3384/project.topka.beacon11 W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
04-21 02:35:22.660 3384-3384/project.topka.beacon11 W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
04-21 02:35:22.720 3384-3384/project.topka.beacon11 D/ChimeraCfgMgr: Reading stored module config
04-21 02:35:22.750 3384-3384/project.topka.beacon11 D/ChimeraFileApk: Primary ABI of requesting process is armeabi-v7a
04-21 02:35:22.750 3384-3384/project.topka.beacon11 D/ChimeraFileApk: Classloading successful. Optimized code found.
04-21 02:35:22.760 3384-3384/project.topka.beacon11 W/asset: Copying FileAsset 0xb91c0318 (zip:/data/data/com.google.android.gms/app_chimera/m/00000000/DynamiteModules-prod.apk:/resources.arsc) to buffer size 372976 to make it aligned.
04-21 02:35:22.790 3384-3384/project.topka.beacon11 I/System: exec(/system/bin/getprop debug.mapview.logs @ maps.db.ag.a:-1)
04-21 02:35:22.820 3384-3384/project.topka.beacon11 I/Google Maps Android API: Google Play services client version: 8487000
04-21 02:35:22.830 3384-3384/project.topka.beacon11 I/Google Maps Android API: Google Play services package version: 8703234
04-21 02:35:22.910 3384-3384/project.topka.beacon11 I/System: exec(/system/bin/getprop debug.mapview.gmmserver @ maps.db.ag.a:-1)
04-21 02:35:23.120 3384-3384/project.topka.beacon11 I/System: exec(/system/bin/getprop debug.mapview.renderer @ maps.db.ag.a:-1)
04-21 02:35:23.730 3384-4653/project.topka.beacon11 I/b: Sending API token request.
04-21 02:35:23.780 3384-3384/project.topka.beacon11 D/FindExtension: FindExtension: before mHardwareRenderer.initialize, mSurface.isValid() = true
04-21 02:35:23.890 3384-3384/project.topka.beacon11 I/LocationProvider: Location services connected.
04-21 02:35:23.900 3384-3384/project.topka.beacon11 D/MapsActivity: Location[fused 40.717675,-73.603164 acc=30 et=+1d6h53m48s501ms]
04-21 02:35:23.990 3384-4653/project.topka.beacon11 E/b: Authentication failed on the server.
04-21 02:35:23.990 3384-4653/project.topka.beacon11 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.
04-21 02:35:24.010 3384-4653/project.topka.beacon11 E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
                                                                               Ensure that the "Google Maps Android API v2" is enabled.
                                                                               Ensure that the following Android Key exists:
                                                                                API Key: AIzaSyBb-7hCOowqJOzUjC6XNJDN7z5JoXKh7Nk
                                                                                Android Application (<cert_fingerprint>;<package_name>): A4:74:47:24:24:22:B4:6E:BD:EA:20:4B:9C:DE:F9:CF:E6:EF:99:0E;project.topka.beacon11

这是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="project.topka.beacon11"
          xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/. 
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="AIzaSyD3R3N7AIE_9pcpfE6UpnFkSYlivwJMTJc"/>

        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps">
        </activity>
        <activity android:name=".SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".CreateBeacon">
        </activity>
        <activity android:name=".IntroScreen">
        </activity>
        <activity android:name=".CreateAccount">
        </activity>
        <activity android:name=".FriendList">
        </activity>
        <activity android:name=".NearbyBeacons">
        </activity>
        <activity android:name=".DatabaseTest">
        </activity>
        <activity android:name=".HTTPTest">
        </activity>

        <receiver
            android:name=".location.UpdateLocationReceiver"
            android:process=":remote" />

        <service
            android:name=".location.UpdateLocationService"
            android:exported="false" />



        <!--
 ATTENTION: This was auto-generated to add Google Play services to your project for
     App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
        -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"/>

        <activity android:name=".LocationTest">
        </activity>
    </application>

</manifest>

这是两个build.gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
        classpath 'com.google.gms:google-services:2.0.0-alpha6'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

文件2:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "project.topka.beacon11"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:design:23.3.0'
    //classpath 'com.google.gms:google-services:2.0.0-alpha6'
}

apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

根据我的经验,当我初始化计时器并将设备小时或日期更改为初始化之前,我收到此消息并且应用程序停止。我不知道这对您的项目是否有意义。

(FindExtension: FindExtension: before mHardwareRenderer.initialize, mSurface.isValid() = true)