Currently, my app is using
Given it's working on other Anrdoid 6.0 devices and you have specified the device you are having complaints on. I suspect, it's not your app. There is a known issue with Sony Xperia z5 on updating to Android 6.0.
Sony claims to have fixed the bug.
Re: "Google Play Store has Stopped" after Z5 Premium Marshmallow Update
AprilHi everyone, I got information today that this will be fixed in the next software update planned to be released soon.
Official Sony Xperia Support Staff
So ensure to advise the client to ensure all Sony updates are current, but this is still not working for all consumer. The bad news is, there is no fix aside from a factory reset, so back to Android 5 and sometimes this fails.
I recommend directing the customer to discuss this with Sony and if a factory reset does not fix the issue, this will be a consumer issue of whether the phone should be replaced.
This thread on the sony mobile website "Google Play Store has Stopped" after Z5 Premium Marshmallow Update discusses these issues at length (122 messages on it) and there are many suggestions, beyond factory reset, for example, using Sony PC companion.
Xperia Z5 Issues After Android Marshmallow Update: Here's A Fix From Sony
Sony Xperia Z5 users' excitement over receiving the Android 6.0 Marshmallow update seems to have been short-lived as users of the handsets are now complaining of issues after updating the device to the latest OS.
Users of the smartphone have taken to the Japanese company's online support page to vent their ire and complain that access to the Google Play Store had halted after updating to Android 6.0 Marshmallow.
Several Xperia Z5 users complained that their smartphones "broke" after installing the new OS. They were also greeted by a pop-up sign that says their "Google Play Store has stopped." The users were also unable to open the Play Store app.
"As soon as I updated to Marshmallow, I keep getting the "Unfortunately Google Play Store has stopped..." and the message keeps coming up every 5 seconds. I tried clearing the cache, deleting data, uninstalling, disabling the app, force closing, signing out of google and back on. Does not work. I keep getting the pop up non-stop and it happened as SOON as it updated to Marshmallow," noted a user on the support forum.
"Yup, having the same problem here. Tried uninstalling the updates in /settings/apps/google play store, also tried installing the .apk through chrome. Still getting the error message. Spoke with customer support and running the "repair" option from Sony Bridge was the only advice they offered. Creating a back-up now before I try running it..." said another.
Sony has acknowledged the problem and has only offered a factory reset.
While this resolves the issue for other Xperia Z5 users, some are still unable to access the Play Store despite performing the reset.
If this is happening on other devices, let me know, as at this point, I would suggest this is the problem without more differentiating details.
I've scoured high and low and given that it's working for most devices and not for a few it's difficult to understand what the problem is. I would suggest running it with the updated dependencies, as the android 6.0 phone uses Google Play Services 9.0.83
, I understand you have run this, but it is better to stay abreast of this.
dependencies {
compile 'com.google.android.gms:play-services:9.0.2'
}
Given there's known bugs with Google services, with Android 6.0 updates and there were many bugs between the Android 5.0 and it's 5.0.1 and 5.0.2 updates. Some more that were fixed in 5.1, it does make it hard to troubleshoot some issues.
I have also faced this issue with an app and people saying a such and such device is not working, and then attempting to trouble shoot it, ans sometimes there can be issues in the users phone settings that can also cause issues with an app and some of these settings vary between handsets.
I'd suggest to create your listeners explicitly within you Builder, and add more logging to check where exactly it is failing within the on failed connection, as you can have connection within the on failed connection and need to manage your connection within the connection call backs.
mGoogleApiClient = new GoogleApiClient.Builder(this.getContext())
.setAccountName(accountName)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addScope(Drive.SCOPE_APPFOLDER)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle bundle) {
if(mGoogleApiClient != null) {
Log.i(TAG, "GoogleApiClient connected");
Activity activity = this.getActivity();
if (activity instanceof ConnectionCallbacks) {
ConnectionCallbacks connectionCallbacks = (ConnectionCallbacks)activity;
connectionCallbacks.onConnected(mGoogleApiClient, action);
}
}
}
@Override
public void onConnectionSuspended(int i) {
mGoogleApiClient.connect();
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "GoogleApiClient connection failed: " + connectionResult.toString());
if (!connectionResult.hasResolution()) {
Utils.showLongToast("debug two " + connectionResult.toString());
// show the localized error dialog.
GoogleApiAvailability.getInstance().getErrorDialog(this.getActivity(), connectionResult.getErrorCode(), 0).show();
return;
}
try {
connectionResult.startResolutionForResult(this.getActivity(), RequestCode.REQUEST_GOOGLE_API_CLIENT_CONNECT);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Exception while starting resolution activity", e);
}
})
.build();
mGoogleApiClient.connect();
}
I would also be adding your class members/variables:
private String accountName = null;
private int action = -1;
private GoogleApiClient mGoogleApiClient;
// etc
To the top of your class, as it's confusing having them at the bottom, and it's better to have readable code.
This question Multiple GoogleApiClient not firing connect() may also be of assistance.
Some side issues for completeness for others landing here:
There will also be the need to update across to Firebase at some point Migrate a GCM Client App for Android to Firebase Cloud Messaging.
From the Release Notes May 2016 - v.9.0
Google Cloud Messaging Google Cloud Messaging (GCM) is integrated with Firebase. Existing users of GCM can continue to use GCM without interruption, though we strongly recommend upgrading to the new and simplified Firebase Cloud Messaging (FCM) APIs, so that users can benefit from future releases of new features and enhancements. To learn more, see Migrate a GCM Client App for Android to Firebase Cloud Messaging.