Google Maps API отображает серый экран вместо отображения карты на Android - PullRequest
0 голосов
/ 02 января 2019

Я пытаюсь отобразить карту Google на Android. Когда я загружаю игру, я получаю серый экран с логотипом Google, отображаемым в левом нижнем углу. Это происходит с использованием виртуального эмулятора и на реальном устройстве. Я попытался использовать другой ключ Api, но получить ту же проблему. Я использую активность карты, предоставленную студией Android.

build.gradle (модуль: приложение)

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

android {
    compileSdkVersion 28
    defaultConfig {

        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'

}

AndroidManifest.xml

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

    <uses-feature
        android:name="android.hardware.sensor.stepcounter"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.sensor.stepdetector"
        android:required="true" />

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">
        <activity android:name=".Activities.LandingActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="redacted" />

        <activity
            android:name=".Activities.MapsActivity"
            android:label="@string/title_activity_maps" />
    </application>

</manifest>

Logcat в режиме ошибки

01-02 15:06:24.913 17090-17160/E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
01-02 15:06:24.923 17090-17160/ 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: ***
        Android Application (<cert_fingerprint>;<package_name>): ***;

enter image description here

Ответы [ 2 ]

0 голосов
/ 02 января 2019

перейдите на консоль Google и попробуйте включить карты SDK для Android ...

0 голосов
/ 02 января 2019

попробуйте заменить аппаратные датчики на ненужные:

<uses-feature
    android:name="android.hardware.sensor.stepcounter"
    android:required="false"/>

<uses-feature
    android:name="android.hardware.sensor.stepdetector"
    android:required="false"/>

, а также это разрешение больше не требуется, в течение многих лет:

<uses-permission android:name="com.google.android.providers.gfs.permission.READ_GSERVICES" />

, и проблема фактически связана с:

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

, который необходимо переместить в самый конец файла.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...