35

Otomatik hata raporları oluşturmak için ACRA (arca.ch) kullanıyorum.GooglePlayServicesUtil.getErrorDialog null

Google Haritalar Android API v2'yi kullanarak uygulamamın yeni bir sürümünü yayınladım. GooglePlayServicesUtil.getErrorDialog tarafından döndürülen iletişim kutusunu göstermeye çalışırken EEEPad ve Transformer Pad kullanıcıları tarafından bildirilen bir hata alıyorum. Bunun neden olabileceğini bilen var mı? Acra tarafından bildirilen Burada

ilgili kod ve Logcat geçerli:

bu satırı çağırarak ederken:

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: Eğer sağlayabilir herhangi bir yardım için şimdiden

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. 

Teşekkür .

Güncelleme

konu henüz google tarafından çözülmüş değil ve ben (Google Hata raporu bağlantıdan CommonsWare cevabını bakın) bir şey duymak bir kez bu soruyu güncellenir.

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(); 
} 
+0

Merhaba DiscDev, showOkDialogWithText() işlevini kullanmaya çalıştığımda, "looper.prepare()" çağrılmayan iş parçacığı içinde işleyici oluşturamıyor "diyerek atma hatası neden UI iş parçacığı yerine çalışan iş parçacığı üzerinde çalışmaya çalışıyor? –

cevap

37

Google suggests (ayrıca docs olarak) sonucunda eğer getErrorDialog() arayarak: Eğer bu sorunu geldi ve çökmesine uygulamanızı istemiyorsanız arada, burada zaman varlık için yapıyorum kod, SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED veya SERVICE_DISABLED şeklindedir. Bu nedenle, olası son durum kodu (SERVICE_INVALID) sorunun nedenidir.

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(); 
} 
+0

Sadece 'GetErrorDialog' ile 'ConnectionResult.SERVICE_INVALID' testini yaptım ve Nexus S üzerinde 'null' var. Bu cevabın doğru olduğunu varsayalım. –

+1

Yani, hep birlikte SERVICE_INVALID göz ardı ediliyor musunuz? Bunun da ele alınması gerekmez mi? – ComputerEngineer88

+0

Bir ** ** GooglePlayServicesUtil ** değil ** GoogleApiAvailability ** kullanılmalıdır. –

22

görüntülemek denemeden önce isUserRecoverableError ile kontrol etmesi gerekir gibi görünüyor:

(platformu 2.3.3 emülatör test) aşağıdaki kodu kullanıyorum ve şimdiye kadar Tamam çalışmak gibi iletişim.

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(); 
     } 
    } 
} 
: Rahim koduna dayanarak
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(); 
    } 
    } 
+3

+1 - GooglePlayServicesUtil.isUserRecoverableError (status) tüm olası eyaletler arasında numaralandırılmasından daha zariftir. –

+0

+1 - Bunu şimdi kullanıyorum, ancak bu soruyu okuduktan sonra, ekleyeceğim bir kontrol olup olmadığına baktığımda, boş değerinizi de kontrol edeceğimi düşünüyorum. – eselk

8

, Google (geri düğmesine basarak) Hizmetler iletişim Play ve Google yüklü Play Hizmetleri olmadan uygulamasını kullanmaya devam görevden kullanıcıyı önleme kabiliyeti eklemek
+0

+1 bu daha eksiksiz çözümü paylaştığınız için teşekkürler. –

+0

Ekstra ek özellik. –

0

@Nevermore tarafından cevabın bir güncelleme, GooglePlayServicesUtil beri yöntemler GoogleApiAvailability lehine kaldırıldı:

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(); 
} 

Not: getErrorDialog()'daki ilk iki parametrenin siparişi, GoogleApiAvailability uygulamasında değiştirilmiştir.

İlgili konular