我正在使用ACRA(arca.ch)生成自动错误报告。
我刚刚使用Google Maps Android API v2发布了我的应用程序的新版本。尝试显示GooglePlayServicesUtil.getErrorDialog返回的对话框时,EEEPad和Transformer Pad用户报告了一个错误。有谁知道为什么会这样?
这是acra报告的相关代码和Logcat:
拨打此行时:
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.
在此先感谢您提供的任何帮助。
更新
google尚未解决该问题,一旦听到任何声音,我将更新此问题(有关Google Bug报告的链接,请参阅CommonsWare的回答)。同时,如果您遇到此问题并且不希望您的应用崩溃,这是我目前正在做的事情:
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();
}
最佳答案
如果结果代码是getErrorDialog()
,SERVICE_MISSING
或SERVICE_VERSION_UPDATE_REQUIRED
,则Google suggests(也在docs中)调用SERVICE_DISABLED
。因此,可能是最后一个可能的状态码(SERVICE_INVALID
)是引起问题的原因。
我正在使用以下代码,到目前为止,它似乎可以正常运行(在仿真器中,平台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();
}
关于android - GooglePlayServicesUtil.getErrorDialog为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13932474/