首页 > 解决方案 > 谷歌地图根本没有加载,没有任何错误

问题描述

谷歌地图仍然闪烁并且不加载。所有脚本、api 密钥和代码都是正确的。

应用程序gradle文件是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.muzammil.bustracking"
        minSdkVersion 15
        targetSdkVersion 26
        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:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services-location:+'
    implementation 'com.google.android.gms:play-services-maps:+'
    implementation 'com.google.firebase:firebase-core:+'
    implementation 'com.google.firebase:firebase-auth:+'

    //noinspection GradleCompatible
    implementation 'com.google.firebase:firebase-messaging:+'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support:design:26.1.0'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//    apply plugin: 'com.google.gms.google-services'
}

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

我在实际的 Android 手机上运行应用程序,而不是模拟器。

非常感谢您的回答...

标签: androidgoogle-mapsandroid-studiogoogle-play-servicesgoogle-places

解决方案


我终于找到了解决办法。

实际上,我是在 API 级别 24 的 Android 设备上运行该应用程序,而该应用程序使用的是 API 级别 26。我将目标 SDK 版本从File > Project Structure > app > flavor从 26 更改为 24 ,它可以正常工作。

谢谢大家帮忙!我真的很感激。


推荐阅读