0

I am having a tough time in finding out the solution of this error:

GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included

I am using CloudPush module, and the weird thing is that till yesterday everything was working perfectly and I was receiving push messages properly. I tried receiving more than 100 push messages.....but suddenly it stopped working and even I am not getting any device token.

var CloudPush = require('ti.cloudpush');

        if (CloudPush.isGooglePlayServicesAvailable()) {
            CloudPush.retrieveDeviceToken({
                success : tokenSuccess,
                error : tokenError
            });

            // Process incoming push notifications
            CloudPush.addEventListener('callback', pushRecieve);
        } else {
            alert("Please enable Google Play Services to register for notifications.");
        }

This is the code I have been using, but God knows why it stopped working suddenly. The only thing I can remember I changed in between is updating the Titanium SDK to 5.3.0.GA, Studio to 4.6.0 and so does everything to its latest version including the CLI also.

But I have been still using 5.2.2, can anyone help me on this or is this going to be rare kind of bug...????

Prashant Saini
  • 3,539
  • 1
  • 10
  • 24

1 Answers1

1

Finally, I found the solution (but do not know what the actual reason was).

I implemented this code:

var CloudPush = require('ti.cloudpush');

Ti.API.info('\n*Play Service = ' + CloudPush.isGooglePlayServicesAvailable());
Ti.API.info('*SERVICE_DISABLED = ' + CloudPush.SERVICE_DISABLED);
Ti.API.info('*SERVICE_INVALID = ' + CloudPush.SERVICE_INVALID);
Ti.API.info('*SERVICE_MISSING = ' + CloudPush.SERVICE_MISSING);
Ti.API.info('*SERVICE_VERSION_UPDATE_REQUIRED = ' + CloudPush.SERVICE_VERSION_UPDATE_REQUIRED);
Ti.API.info('*SUCCESS = ' + CloudPush.SUCCESS);


if (CloudPush.isGooglePlayServicesAvailable() == 0) {
    CloudPush.retrieveDeviceToken({
        success : function (e) {
           Ti.API.info('** deviceToken == ' + e.deviceToken);
        },
        error : tokenError
    });

    CloudPush.addEventListener('callback', pushRecieve);

} else {
    CloudPush.clearStatus();
    CloudPush.retrieveDeviceToken({
        success : function (e) {
           Ti.API.info('** deviceToken == ' + e.deviceToken);
        },
        error : tokenError
    });
}

So, the solution was to call this method CloudPush.clearStatus() and getting token again.

But still the error is there on console inspite that I am receiving the token successfully.

This is the console output:

[INFO] :  GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

[INFO] :  *Play Service = 0
[INFO] :  *SERVICE_DISABLED = 3
[INFO] :  *SERVICE_INVALID = 9
[INFO] :  *SERVICE_MISSING = 1
[INFO] :  *SERVICE_VERSION_UPDATE_REQUIRED = 2
[INFO] :  *SUCCESS = 0

[INFO] :  GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
[INFO] :   ** deviceToken == AP.......qK

In my previous code, I did a mistake that I thought CloudPush.isGooglePlayServicesAvailable() will return true for success, but it actually returns a number (printed above), then I got the idea of making it correct.

But it did not work either until I called CloudPush.clearStatus().

Hope it will help someone :)

Prashant Saini
  • 3,539
  • 1
  • 10
  • 24
  • I'm not sure the clearStatus() call is responsible for your code working again. I have a number of apps that do a LOT of push messaging (around 200,000 users getting 10 notifications daily), and we don't use that call at all. Your revised code's logic looks strange, too. When google play services is not available, you are continuing to get the device token and add the event listener. If play services is not available, it's because you're running on a device that *can't* use them (like a Kindle Fire); you're not going to be able to send GCM push notifications to those devices. – Jason Priebe Jun 06 '16 at 14:38
  • Whatever the code is, it worked for me after struggling around for more than 8 hours. Initially there was no code to check for Play services and everything was working so well. But suddenly tokenError method was started calling on same device I was using Push from almost 1 week. Then it stopped working on other devices also. Like I already said that I do not know the reason why it stopped and why it worked. But that was the only quick solution instead of waiting on here. :) – Prashant Saini Jun 06 '16 at 14:54
  • One thing that is probably misleading you a little bit is the "GooglePlayServicesUtil: The Google Play services resources were not found." error message. That is a known message that is safe to ignore. See this thread: http://stackoverflow.com/questions/18068627/logcat-message-the-google-play-services-resources-were-not-found-check-your-pr/21686918#21686918 – Jason Priebe Jun 06 '16 at 15:15
  • Oh man, it seems that this device token error is not leaving me behind and it started to happen again. I am totally frustrated as I have already implemented it in other apps but it is not working in just this app. – Prashant Saini Jun 06 '16 at 15:47
  • I got the error on console a little bit further. [ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. [WARN] : W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.louis.btapp/shared_prefs/aps.preferences.xml.bak If I do not get token or remove CloudPush module, then I do not get any such error of missing aps.preferences.xml.bak file. Please help me to solve this. – Prashant Saini Jun 06 '16 at 15:49
  • I don't know what that file is, but if I had to guess, I think it is the shared preferences file that is getting removed when you call clearStatus(). The source to CloudPush is not open, so I can't be sure what's happening under the hood, but I bet it is trying to delete com.louis.btapp/shared_prefs/aps.preferences.xml and com.louis.btapp/shared_prefs/aps.preferences.xml.bak. The bak file does not exist, and they're probably not doing enough error checking. The log entry is most likely harmless, but it's hard to be certain. – Jason Priebe Jun 06 '16 at 16:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/113951/discussion-between-prashant-saini-and-jason-priebe). – Prashant Saini Jun 06 '16 at 16:52
  • Hi Jason, can you please help me solve this issue. I have tried different things whatever I could, but its still there and I have no idea at all why this happening a sudden. Can you please send me a Skype request on prashant_saini@outlook.com ? – Prashant Saini Jun 06 '16 at 16:57
  • I'm not going to have time to work through this directly with you. I can send you a code sample offline, though. – Jason Priebe Jun 06 '16 at 18:41