Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 274
Rohan Patel Avatar asked Oct 31 '19 06:10

Rohan Patel


3 Answers

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.

like image 88
masterwok Avatar answered Nov 15 '22 20:11

masterwok


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.

like image 3
Julio Mendoza Avatar answered Nov 15 '22 20:11

Julio Mendoza


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

like image 1
Dmitriy Avatar answered Nov 15 '22 19:11

Dmitriy