Missing Google Play Services from AVD

后端 未结 7 1051
南旧
南旧 2020-12-28 08:24

I recently started developing for Android, and I have come into trouble when trying to use Google Maps in my app. I downloaded the Google Maps API v2 for Android, and have a

7条回答
  •  别那么骄傲
    2020-12-28 08:42

    If anyone is still experiencing this issue, first try to create your emulator with the Google API's as the platform target. After doing so, I noticed that my Google Play Services was not the correct version on the emulator.

    While trying to hack together a solution, I stumbled upon the GoogleApiAvailability class here. Google did a phenomenal job handling compatibility issues.

    GoogleApiAvailability.isGooglePlayServicesAvailable(Context) returns an integer status code, which can be fed directly into getErrorDialog(Activity, errorCode, requestCode) which returns a Dialog that works perfectly right out of the box. If your Play Services are out of date, the dialog will redirect you to an updater... If they are missing, it will redirect you to an installer, etc...

    Thought I would share this great feature in case anyone is looking for a fix that would work in production code as well as testing.

提交回复
热议问题