谷歌地图未显示在具有android os版本6的设备上

时间:2016-06-21 09:15:15

标签: android google-maps

我正在构建包含地图的应用程序,并且在具有android os版本6的HTC设备上进行测试时,地图未显示

任何人都能帮帮我吗?

3 个答案:

答案 0 :(得分:0)

检查是否安装了Google Play服务并检查SHA密钥是否正确.Google地图不是特定于设备的。

答案 1 :(得分:0)

  

地图未显示

原因可以是以下之一:

public static boolean isGooglePlayServiceAvailable(Activity context)
{
            GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
        int resultCode = apiAvailability.isGooglePlayServicesAvailable(context);
        if (resultCode != ConnectionResult.SUCCESS) {
            if (apiAvailability.isUserResolvableError(resultCode)) {
                apiAvailability.getErrorDialog(context, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                        .show();
            }else{
                Toast.makeText(context, "This device is not supported. Google Play Services not installed!", Toast.LENGTH_LONG).show();
                return false;
            }
        }else{
            return true;
        }
        return true;
}
  • 另一个原因可能是app在AndroidManifest中错误gcm_defaultSenderId或错误的API KEY值
<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="A****************************E" />

答案 2 :(得分:0)

您是否在运行时请求了许可?

来自Android 6的用户在应用运行时向应用授予权限,而不是在他们安装应用时授予权限。

点击此处查看如何申请权限: https://developer.android.com/training/permissions/requesting.html

相关问题