Rohan Patel
Rohan Patel

Reputation: 1858

Failed to bind to the service

On the app launch, I need to check whether a new version is available on play store or not. To check I have implemented below code in Splash screen.

private void checkNewVersionAvailability() {
    appUpdateManager = AppUpdateManagerFactory.create(getApplicationContext());
    appUpdateInfo = appUpdateManager.getAppUpdateInfo();

    appUpdateInfo.addOnCompleteListener(new OnCompleteListener<AppUpdateInfo>() {
        @Override
        public void onComplete(Task<AppUpdateInfo> task) {
            if (task.isComplete()) {
                if (task.getResult().updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
                    checkVersion(task.getResult());
                } else if (task.getResult().updateAvailability() == UpdateAvailability.UPDATE_NOT_AVAILABLE) {
                    if (StringUtils.isNullOrEmpty(ChevronApplication.deviceId)) {
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                RegsiterDeviceHandler handler = new RegsiterDeviceHandler(SplashScreen.this);
                                handler.registerDevice(false);
                                handler.showNextScreen();
                            }
                        }, SLEEP_TIME);
                    } else {
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                new RegsiterDeviceHandler(SplashScreen.this).showNextScreen();
                            }
                        }, SLEEP_TIME);
                    }
                }
            }
        }
    });

During testing on the device, I didn't get the issue. These crash logs are I found from the Pre-launch report in Playstore. enter image description here

> FATAL EXCEPTION: main
Process: com.mac.app, PID: 19641
com.google.android.play.core.tasks.RuntimeExecutionException: com.google.android.play.core.internal.aa: Failed to bind to the service.
    at com.google.android.play.core.tasks.k.getResult(Unknown Source)
    at com.chevronrenaissance.app.activity.SplashScreen$2.onComplete(SplashScreen.java:113)
    at com.google.android.play.core.tasks.a.run(Unknown Source)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5538)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: com.google.android.play.core.internal.aa: Failed to bind to the service.
    at com.google.android.play.core.internal.q.b(Unknown Source)
    at com.google.android.play.core.internal.q.a(Unknown Source)
    at com.google.android.play.core.internal.s.a(Unknown Source)
    at com.google.android.play.core.internal.r.run(Unknown Source)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.os.HandlerThread.run(HandlerThread.java:61)

Upvotes: 16

Views: 12955

Answers (5)

Md omer arafat
Md omer arafat

Reputation: 466

If you are running it in a emulator and if emulator is not signed for Google play, it will show the error that "PID: [6084] AppUpdateService : Failed to bind to the service."

Upvotes: -1

Roar Gr&#248;nmo
Roar Gr&#248;nmo

Reputation: 3966

Most likely that the Emulator you are using do not contain Google Play at all.

Upvotes: 0

masterwok
masterwok

Reputation: 5131

I was running a very similar issue using the in-app review component. It turned out one of the emulators I was developing with had not been signed into a Google Play account. You may want to ensure your emulator is signed into Google Play.

Upvotes: 2

Dmitriy
Dmitriy

Reputation: 133

You can check task.isSuccessful(). In this case, when the task is not successful, you can get the exception use method task.getException()

Upvotes: 1

Julio Mendoza
Julio Mendoza

Reputation: 310

There seems to be an issue with Google Play Core library with Android Virtual Devices. I had to add a try/catch statement so the Pre-launch testing passes. I think you may have to wrap al your AppUpdateManager calls so the exception is catched.

Upvotes: 3

Related Questions