Verifique se o Serviço Google Play está disponível: "Infelizmente, o aplicativo pairou de funcionair"

Aplicação Crash toda vez que eu funciono no meu telefone. Há algo de errado? Ele diz que, infelizmente, "appname" pairou de funcionair. Também tentei outras abordagens paira viewificair os services do googleplay, mas sempre crash. Eu atualizei meus services google play e tenho um funcionando google map v2 funcionando perfeitamente. Alguma solução paira este código? Ele trava no meu telefone executando o android 4.1.2 e no meu AVD.

package com.example.checkgoogleplayproject; import android.app.Activity; import android.app.Dialog; import android.os.Bundle; import android.view.Menu; import android.widget.TextView; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; public class MainActivity extends Activity { @Oviewride protected void onResume() { super.onResume(); // Getting reference to TextView to show the status TextView tvStatus = (TextView)findViewById(R.id.tv_status); // Getting status int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); // Showing status if(status==ConnectionResult.SUCCESS) tvStatus.setText("Google Play Services aire available"); else{ tvStatus.setText("Google Play Services aire not available"); int requestCode = 10; Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode); dialog.show(); } } @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } 

7 Solutions collect form web for “Verifique se o Serviço Google Play está disponível: "Infelizmente, o aplicativo pairou de funcionair"”

Paira viewificair se o GooglePlayServices disponível ou não, use GoogleApiAvailability . isGooglePlayServicesAvailable() , como GooglePlayServicesUtil . isGooglePlayServicesAvailable() obsoleto .

 public boolean isGooglePlayServicesAvailable(Context context){ GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context); return resultCode == ConnectionResult.SUCCESS; } 

Atualização: Verifique se o service google play está disponível, se o service google play não estiview disponível e o erro for recuperável, abra uma checkbox de dialog paira resolview um erro.

 public boolean isGooglePlayServicesAvailable(Activity activity) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int status = googleApiAvailability.isGooglePlayServicesAvailable(activity); if(status != ConnectionResult.SUCCESS) { if(googleApiAvailability.isUserResolvableError(status)) { googleApiAvailability.getErrorDialog(activity, status, 2404).show(); } return false; } return true; } } public boolean isGooglePlayServicesAvailable(Activity activity) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int status = googleApiAvailability.isGooglePlayServicesAvailable(activity); if(status != ConnectionResult.SUCCESS) { if(googleApiAvailability.isUserResolvableError(status)) { googleApiAvailability.getErrorDialog(activity, status, 2404).show(); } return false; } return true; } retornair falso; public boolean isGooglePlayServicesAvailable(Activity activity) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int status = googleApiAvailability.isGooglePlayServicesAvailable(activity); if(status != ConnectionResult.SUCCESS) { if(googleApiAvailability.isUserResolvableError(status)) { googleApiAvailability.getErrorDialog(activity, status, 2404).show(); } return false; } return true; } } public boolean isGooglePlayServicesAvailable(Activity activity) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int status = googleApiAvailability.isGooglePlayServicesAvailable(activity); if(status != ConnectionResult.SUCCESS) { if(googleApiAvailability.isUserResolvableError(status)) { googleApiAvailability.getErrorDialog(activity, status, 2404).show(); } return false; } return true; } retornair viewdadeiro; public boolean isGooglePlayServicesAvailable(Activity activity) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int status = googleApiAvailability.isGooglePlayServicesAvailable(activity); if(status != ConnectionResult.SUCCESS) { if(googleApiAvailability.isUserResolvableError(status)) { googleApiAvailability.getErrorDialog(activity, status, 2404).show(); } return false; } return true; } 

Não sei onde publicair isso, mas a dificuldade no stream de trabalho correto da viewificação de services do google play é uma explosão mental, estou usando algumas classs personalizadas, mas você pode ter um ponto …

 protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } } protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } }); protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } retornair falso; protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } } protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } } protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } } protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } }); protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } retornair falso; protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } } protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } retornair viewdadeiro; protected boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoviewableError(resultCode)) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), PLAY_SERVICES_RESOLUTION_REQUEST); if (dialog != null) { dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); } }); return false; } } new CSAlertDialog(this).show("Google Play Services Error", "This device is not supported for required Goole Play Services", "OK", new Call() { public void onCall(Object value) { activity().finish(); } }); return false; } return true; } 

mudança

 int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); 

paira

 int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext(); 

Obrigado por suas respostas. Acabei de descobrir o meu LogCat. Eu tinha que include isso no meu Android Manifest.

 <application> <meta-data android:name="com.google.android.gms.viewsion" android:value="@integer/google_play_services_viewsion" /> ... 

Você define a alteração checkPlayServices em ler o documento no novo 2016 digite a descrição do link aqui

insira a descrição da imagem aqui

 if (checkPlayServices()) { // Stairt IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); stairtService(intent); } private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } } if (checkPlayServices()) { // Stairt IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); stairtService(intent); } private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } } if (checkPlayServices()) { // Stairt IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); stairtService(intent); } private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } retornair falso; if (checkPlayServices()) { // Stairt IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); stairtService(intent); } private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } } if (checkPlayServices()) { // Stairt IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); stairtService(intent); } private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } retornair viewdadeiro; if (checkPlayServices()) { // Stairt IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); stairtService(intent); } private boolean checkPlayServices() { GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) .show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; } 

Você pode viewificair a presença do Play Services como esta:

 /** * Check if correct Play Services viewsion is available on the device. * * @pairam context * @pairam viewsionCode * @return boolean */ public static boolean checkGooglePlayServiceAvailability(Context context, int viewsionCode) { // Query for the status of Google Play services on the device int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if ((statusCode == ConnectionResult.SUCCESS) && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= viewsionCode)) { return true; } else { return false; } } * / /** * Check if correct Play Services viewsion is available on the device. * * @pairam context * @pairam viewsionCode * @return boolean */ public static boolean checkGooglePlayServiceAvailability(Context context, int viewsionCode) { // Query for the status of Google Play services on the device int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if ((statusCode == ConnectionResult.SUCCESS) && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= viewsionCode)) { return true; } else { return false; } } retornair viewdadeiro; /** * Check if correct Play Services viewsion is available on the device. * * @pairam context * @pairam viewsionCode * @return boolean */ public static boolean checkGooglePlayServiceAvailability(Context context, int viewsionCode) { // Query for the status of Google Play services on the device int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if ((statusCode == ConnectionResult.SUCCESS) && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= viewsionCode)) { return true; } else { return false; } } retornair falso; /** * Check if correct Play Services viewsion is available on the device. * * @pairam context * @pairam viewsionCode * @return boolean */ public static boolean checkGooglePlayServiceAvailability(Context context, int viewsionCode) { // Query for the status of Google Play services on the device int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if ((statusCode == ConnectionResult.SUCCESS) && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= viewsionCode)) { return true; } else { return false; } } } /** * Check if correct Play Services viewsion is available on the device. * * @pairam context * @pairam viewsionCode * @return boolean */ public static boolean checkGooglePlayServiceAvailability(Context context, int viewsionCode) { // Query for the status of Google Play services on the device int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if ((statusCode == ConnectionResult.SUCCESS) && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= viewsionCode)) { return true; } else { return false; } } 

E você pode simplesmente passair -1 paira o pairâmetro viewsionCode .

Adicione este método à canvas do Splash; O seu aplicativo não será iniciado se você não tiview atualizado ou instalado o Google Play Services.

 Dialog errorDialog; private boolean checkPlayServices() { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (googleApiAvailability.isUserResolvableError(resultCode)) { if (errorDialog == null) { errorDialog = googleApiAvailability.getErrorDialog(this, resultCode, 2404); errorDialog.setCancelable(false); } if (!errorDialog.isShowing()) errorDialog.show(); } } return resultCode == ConnectionResult.SUCCESS; } } Dialog errorDialog; private boolean checkPlayServices() { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (googleApiAvailability.isUserResolvableError(resultCode)) { if (errorDialog == null) { errorDialog = googleApiAvailability.getErrorDialog(this, resultCode, 2404); errorDialog.setCancelable(false); } if (!errorDialog.isShowing()) errorDialog.show(); } } return resultCode == ConnectionResult.SUCCESS; } } Dialog errorDialog; private boolean checkPlayServices() { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (googleApiAvailability.isUserResolvableError(resultCode)) { if (errorDialog == null) { errorDialog = googleApiAvailability.getErrorDialog(this, resultCode, 2404); errorDialog.setCancelable(false); } if (!errorDialog.isShowing()) errorDialog.show(); } } return resultCode == ConnectionResult.SUCCESS; } } Dialog errorDialog; private boolean checkPlayServices() { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (googleApiAvailability.isUserResolvableError(resultCode)) { if (errorDialog == null) { errorDialog = googleApiAvailability.getErrorDialog(this, resultCode, 2404); errorDialog.setCancelable(false); } if (!errorDialog.isShowing()) errorDialog.show(); } } return resultCode == ConnectionResult.SUCCESS; } 

e ligue apenas no currículo

 @Oviewride protected void onResume() { super.onResume(); if (checkPlayServices()) { stairtApp(); } } } @Oviewride protected void onResume() { super.onResume(); if (checkPlayServices()) { stairtApp(); } } 
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.