Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange dialog with GooglePlayServicesUtil

Tags:

android

I'm checking avalibility of google play services on device. I do it with these code:

final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
 final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(final DialogInterface dialog) {
                    finish();
                }
            };
            final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
                    resultCode, this, GOOGLE_PLAY_SERVICES_REQUEST_CODE, cancelListener
            );
            errorDialog.show();
}

I get resultCode = 2 (it's mean that Google Play Services needs to update). Dialog is shown, but instead of text, I get paths to layout.

enter image description here

It's looks like there are some interference of resource in app and resource in PlaYServices lib. But how it's possible and how to avoid id?

like image 698
Alexander Mikhaylov Avatar asked Nov 30 '25 02:11

Alexander Mikhaylov


1 Answers

Since the accepted answer is somewhat unclear, I'll leave a signpost with my conclusions (mostly extracted from the comments on the question) which I believe are correct.

Short version: It seems that resource ids were incorrectly generated for this app.

It's obvious that the Google Play Services dialog intended to show strings in those places. The getErrorDialog() method is implemented like this (obfuscated, but the meaning can still be understood):

...
case 1: 
    return localBuilder.setTitle(R.string.common_google_play_services_install_title).create();
case 3: 
    return localBuilder.setTitle(R.string.common_google_play_services_enable_title).create();
case 2: 
   return localBuilder.setTitle(R.string.common_google_play_services_update_title).create();
...

Also, mistakenly doing something like getResources().getString(R.layout.my_layout) will return a string with the name of the original resource file ("res/layout/my_layout.xml").

So, we can conclude that, for some reason, the value of the Play Services Library resource, say, com.google.android.gms.R.string.common_google_play_services_install_title is actually the same as for the resource R.layout.dialog_share in the application project.

This probably stems for an incorrect build process, or an incorrect usage of the Google Play Services library (for example, including its jar directly, without the corresponding library process).

like image 143
matiash Avatar answered Dec 02 '25 15:12

matiash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!