App won't run unless you update Google Play services

谁说我不能喝 提交于 2019-12-20 06:27:42

问题


I'm fairly new to developing and have my Google Maps API working perfectly, only snag I have is that in my gradle dependencies I have to compile 'com.google.android.gms:play-services:9.+' instead of play-services 10.0.1.

When I use 10.0.1 on my emulator (the android studio emulator, api25), I open my maps activity I just get

com.android.tools.fd.runtime.BootstrapApplication won't run unless you update Google Play services.

I have all the needed packages installed and everything, not sure why, but no issues at all when I use "play-services:9.+".

However, trying to link my app into Firebase, obviously requires me to use 10.0.1. Is there anything I can do to fix both issues?


回答1:


Any device or emulator will need to have at minimum the version of Google Play Services that your app is compiled with. Standard practice is to prompt the user to upgrade if the version of Google Play Services on the device is lower than needed.

Here is the new way to prompt the user to upgrade Google Play Services. Call this checkPlayServices() method when your app is first launched:

public static final int PLAY_SERVICES_RESOLUTION_REQUEST = 999;
GoogleApiAvailability googleAPI;
private boolean checkPlayServices() {
    googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(this);
    if(result != ConnectionResult.SUCCESS) {
        if(googleAPI.isUserResolvableError(result)) {
            googleAPI.getErrorDialog(this, result,
                    PLAY_SERVICES_RESOLUTION_REQUEST).show();
        }

        return false;
    }

    return true;
}

If the device has an older version of Google Play Services, the update prompt will be shown:



来源:https://stackoverflow.com/questions/41474817/app-wont-run-unless-you-update-google-play-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!