GooglePlayServicesUtil.getErrorDialog es nulo

Estoy utilizando ACRA ( arca.ch ) para generar informes de errores automáticos.

Acabo de publicar una nueva versión de mi aplicación mediante Google Maps Android API v2. Estoy recibiendo un error informado por los usuarios de EEEPad y Transformer Pad al intentar mostrar el cuadro de diálogo devuelto por GooglePlayServicesUtil.getErrorDialog. ¿Alguien sabe por qué esto podría suceder?

Aquí está el código relevante y Logcat según lo reportado por acra:

Mientras llamaba a esta línea:

int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if(resultCode != ConnectionResult.SUCCESS) { //The dialog that comes back is null (probably due to the logcat message) Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 69); //So when I call the next line, the app crashes with a NullPointerException dialog.show(); } ... 

Logcat:

 12-18 04:21:04.531 W/GooglePlayServicesUtil( 3977): Google Play Store signature invalid. 12-18 04:21:04.551 E/GooglePlayServicesUtil( 3977): Google Play services is invalid. Cannot recover. 

Gracias de antemano por cualquier ayuda que pueda proporcionar.

Actualizar

El problema aún no ha sido resuelto por google y actualizaré esta pregunta una vez que escuche algo (vea la respuesta de CommonsWare para el enlace de informe de errores de Google). Mientras tanto, si te encuentras con este problema y no quieres que tu aplicación se bloquee, esto es lo que estoy haciendo por el momento:

 public void checkGooglePlayServicesAvailability() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if(resultCode != ConnectionResult.SUCCESS) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 69); if(dialog != null) { dialog.show(); } else { showOkDialogWithText(this, "Something went wrong. Please make sure that you have the Play Store installed and that you are connected to the internet. Contact developer with details if this persists."); } } Log.d("GooglePlayServicesUtil Check", "Result is: " + resultCode); } public static void showOkDialogWithText(Context context, String messageText) { Builder builder = new AlertDialog.Builder(context); builder.setMessage(messageText); builder.setCancelable(true); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.create(); dialog.show(); } 

Google sugiere (también en docs ) llamar a getErrorDialog() si el código de resultado es SERVICE_MISSING , SERVICE_VERSION_UPDATE_REQUIRED o SERVICE_DISABLED . Por lo tanto, es posible que el último código de estado posible ( SERVICE_INVALID ) sea lo que causa problemas.

Estoy utilizando el siguiente código y hasta ahora parece que funciona bien (prueba en el emulador, la plataforma 2.3.3):

 int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity.getApplicationContext()); if (resultCode == ConnectionResult.SUCCESS) { activity.selectMap(); } else if (resultCode == ConnectionResult.SERVICE_MISSING || resultCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED || resultCode == ConnectionResult.SERVICE_DISABLED) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity, 1); dialog.show(); } 

Parece que tienes que comprobar con isUserRecoverableError antes de intentar mostrar el diálogo.

  int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (status != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(status)) { GooglePlayServicesUtil.getErrorDialog(status, this, REQUEST_CODE_RECOVER_PLAY_SERVICES).show(); } else { Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show(); finish(); } } 

Sobre la base del código de Rahim, agrego la capacidad de evitar que el usuario descarte el cuadro de diálogo de Servicios de Google Play (pulsando el botón Atrás) y continúe usando la aplicación sin los Servicios de Google Play instalados:

 private void checkGooglePlayServicesAvailable() { int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (status != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(status)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, 0); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { MainActivity.this.finish(); } }); dialog.show(); } else { Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show(); finish(); } } } 

Una actualización de la respuesta por @Nevermore , ya que los métodos de GooglePlayServicesUtil están en desuso a favor de GoogleApiAvailability :

 GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(activity.getApplicationContext()); if (resultCode == ConnectionResult.SUCCESS) { activity.selectMap(); } else if (resultCode == ConnectionResult.SERVICE_MISSING || resultCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED || resultCode == ConnectionResult.SERVICE_DISABLED) { Dialog dialog = googleApiAvailability.getErrorDialog(activity, resultCode, 1); dialog.show(); } 

Observe que el orden de los dos primeros parámetros en getErrorDialog() se ha cambiado en la implementación de GoogleApiAvailability .

  • Cómo mantener sin problemas el marcador de ubicación actual en Google Maps v2 android
  • Posicionamiento de Google Maps v2 zoom en controles en Android
  • Route-Me para Android
  • ¿Qué es el nivel de zoom 15 equivalente a?
  • Android || Obtener la información actual de la ruta de Google Maps
  • Google maps glitch en los teléfonos Motorola
  • Límite de uso del mapa Google V3 en las aplicaciones Phonegap
  • DeslizamientoDirector sobre GoogleMap
  • Google Map en dispositivos móviles
  • ¿Dónde encuentro el texto de atribución de Google Play Services?
  • Android - google map mover la cámara de una posición a otra
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.