Failed to bind to the service - android

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.
> 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)

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.

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.

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

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

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."

Related

Problem to integrate Jitsi Meet Sdk with linphone

I am using JItsi meet api for video call on linphone android app open source project. I have followed jitsi meet handbook for integrating on linphone.
Here is my sample code:
public class JitsiActivity extends AppCompatActivity {
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
URL serverURL;
try {
serverURL = new URL("https://meet.jit.si");
} catch (MalformedURLException e) {
e.printStackTrace();
throw new RuntimeException("Invalid server URL!");
}
JitsiMeetConferenceOptions defaultOptions =
new JitsiMeetConferenceOptions.Builder()
.setServerURL(serverURL)
.setWelcomePageEnabled(false)
.build();
JitsiMeet.setDefaultConferenceOptions(defaultOptions);
JitsiMeetConferenceOptions options =
new JitsiMeetConferenceOptions.Builder().setRoom("linphone").build();
JitsiMeetActivity.launch(this, options);
finish();
}
}
I have successfully made a call on debug mode, after making an apk on release mode, It refresh activity when I attempt to make a video call and go to home page. can you give me a guideline to solve this problem. I have tested apk on Android 10 OS.
--After Debugging on release mode I have found this error
020-09-24 16:50:12.383 10364-10364/org.linphone E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.linphone, PID: 10364
java.lang.IllegalArgumentException: reportSizeConfigurations: ActivityRecord not found for: Token{2329006 ActivityRecord{cf5fae1 u0 org.linphone/.activities.JitsiActivity d-1 s-1 t-1 f}}
at android.os.Parcel.createException(Parcel.java:1967)
at android.os.Parcel.readException(Parcel.java:1931)
at android.os.Parcel.readException(Parcel.java:1881)
at android.app.IActivityManager$Stub$Proxy.reportSizeConfigurations(IActivityManager.java:8621)
at android.app.ActivityThread.reportSizeConfigurations(ActivityThread.java:3360)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3318)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2043)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7096)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.reportSizeConfigurations(ActivityManagerService.java:10305)
at android.app.IActivityManager$Stub.onTransact$reportSizeConfigurations$(IActivityManager.java:12560)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2357)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3841)
at android.os.Binder.execTransact(Binder.java:750)
You need to provide a stacktrace to for anyone to help you debug it, however, this code can be simplified greatly which would lead to easier debugging..
You are supplying Jitsi with it's own default server url "https://meet.jit.si" which isn't necessary as Jitsi will use it's own server anyway. If you were planning on using your own server you can still provide that easily in the JitsiMeetActivity::launch method as the room parameter...
JitsiMeetActivity.launch(context, "https://myserver.com/linphone")
Removing all the unnecessary boiler-plate will leave you with this:
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
JitsiMeetActivity.launch(this, "linphone");
}

Android ChromeCast RuntimeException : Remote load failed. No local fallback found

I am using cast feature in my application. It was working fine but suddenly I can see the increase in the number of crashes on play store console.
I am initializing CastContext properly as defined in the guidelines and Moreover, I am checking that device is compatible or not before calling this method CastContext.getSharedInstance(context) So that should not be an issue.
I am not able to reproduce this crash even on emulators with or without google-play-services one.
Any help will be appreciated.
Crash :
Fatal Exception: java.lang.RuntimeException: Unable to start activity
ComponentInfo{... .activity.TVActivityPhone}:
java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zza: Remote load
failed. No local fallback found. at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2747)
at android.app.ActivityThread.access$900(ActivityThread.java:187) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
at android.os.Handler.dispatchMessage(Handler.java:111) at
android.os.Looper.loop(Looper.java:194) at
android.app.ActivityThread.main(ActivityThread.java:5877) at
java.lang.reflect.Method.invoke(Method.java) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) Caused
by java.lang.RuntimeException:
com.google.android.gms.dynamite.DynamiteModule$zza: Remote load
failed. No local fallback found.
Code I am getting an error inside the if the condition that means, it's not about the google play service availability.
if (googlePlayServicesVerified(context)) { // checking (result==ConnectionResult.SUCCES)
Log.d("TAG", "instantiated");
castContext = CastContext.getSharedInstance(context);
} else {
Log.e(TAG, "FAILED");
}
Filed bug to google:
https://issuetracker.google.com/issues/65359941
** Update **
Check these two issues :
https://issuetracker.google.com/issues/65359941
https://issuetracker.google.com/issues/79405933
The temporary solution is in my answer.
This is the temporary solution.
1) Your app should always check GPS version before using any Cast APIs
2) Allow CastContext.getSharedInstance() to fail. Probably throw/catch an exception (or alternatively return null).
3) Make sure, you don't break anything if the dynamite module fails to load. There are some UI widgets that are initialized implicitly which calls CastContext.getSharedInstance(), such as MiniControllerFragment. You should avoid letting it crash if dynamite fails to load.
public static boolean isAvailable(Context context)
{
GoogleApiAvailability availability = GoogleApiAvailability.getInstance();
return isGooglePlayServicesAvailable(context, availability) &&
isCastContextAvailable(context);
}
public static boolean isAvailable(Context context) {
if (googlePlayServicesVerified(context)) {
try {
castContext = CastContext.getSharedInstance(context);
Log.d(TAG, "CastContext instantiated");
} catch (Exception e) {
Log.report(e);
castContext = null;
}
} else {
CrashReporter.report("CastContext FAILED to be instantiated : googlePlayServicesVerified() has failed."));
castContext = null;
}
}
I get this issue when play services are out of date (mainly on emulators running API 24). This worked for me:
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) {
googleApiAvailability.getErrorDialog(this, resultCode, 1000).show();
return;
}
startApp();
I run this code in an Activity which checks if MainActivity should be started

How to avoid TagManager "IllegalStateException: Results have already been set"

I have recently introduced Google TagManager into my Android app in order to push changes to app config without needing to redeploy the app.
But I am getting instances of:
java.lang.IllegalStateException: Results have already been set
at com.google.android.gms.common.internal.p.a(Unknown Source)
at com.google.android.gms.common.api.b$a.a(Unknown Source)
at com.google.android.gms.tagmanager.ed.a(Unknown Source)
at com.google.android.gms.tagmanager.ed.a(Unknown Source)
at com.google.android.gms.tagmanager.ed$b.a(Unknown Source)
at com.google.android.gms.tagmanager.ed$b.a(Unknown Source)
at com.google.android.gms.tagmanager.cj.c(Unknown Source)
at com.google.android.gms.tagmanager.ck.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
They occur across a variety of devices from Android 4.4 to 5.0.1
As you can see there is no element of my app in the stacktrace, and I am really at a loss and to what I can do (other than remove TagManager) to avoid or mitigate the error.
I have found one reference to the same error message associated with GooglePlus login so I am thinking it might be to do with the Google Play Services library.
Anyone else seen it?
Any ideas?
Have raised issue with Play-Games project:
https://code.google.com/p/play-games-platform/issues/detail?id=209
This is an internal bug due to a race condition within TagManager and should be fixed in Google Play Services 6.7 (February 17, 2015).
See https://productforums.google.com/forum/?utm_medium=email&utm_source=footer#!msg/tag-manager/NOlng117_2g/w46OkQS5Gm8J
and also https://developers.google.com/analytics/devguides/collection/android/changelog
In the mean time you can work around it by:
private static class MyHandler implements Thread.UncaughtExceptionHandler {
private final Thread.UncaughtExceptionHandler defaultHandler;
MyHandler(Thread.UncaughtExceptionHandler defaultHandler) {
this.defaultHandler = defaultHandler;
}
#Override
public void uncaughtException(Thread thread, Throwable ex) {
String classpath = null;
if (ex != null && ex.getStackTrace().length > 0) {
classpath = ex.getStackTrace()[0].toString();
}
if (classpath != null &&
ex.getMessage().contains("Results have already been set") &&
classpath.contains("com.google.android.gms.tagmanager") ) {
// ignore
} else {
// run your default handler
defaultHandler.uncaughtException(thread, ex);
}
}
};
// Application#onCreate
public void onCreate() {
// for catching app global unhandled exceptions
final Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new MyHandler(defaultHandler));
}
According to this link, Google has fixed this issue in newer versions:
https://developers.google.com/analytics/devguides/collection/android/changelog

"GoogleApiClient is not connected yet" exception in Cast application

I'm developing an Android application that casts content to Chromecast.
Sometimes in my com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks implementation in the onConnected method, I get a
java.lang.IllegalStateException: GoogleApiClient is not connected yet.
exception.
Here is the stack trace:
FATAL EXCEPTION: main
Process: com.joaomgcd.autocast, PID: 13771
java.lang.IllegalStateException: GoogleApiClient is not connected yet.
at com.google.android.gms.internal.eg.a(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient.b(Unknown Source)
at com.google.android.gms.cast.Cast$CastApi$a.launchApplication(Unknown Source)
at com.joaomgcd.autocast.media.MediaConnectionCallbacks.onConnected(MediaConnectionCallbacks.java:37)
at com.google.android.gms.internal.dx.b(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient.bn(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient.f(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$2.onConnected(Unknown Source)
at com.google.android.gms.internal.dx.b(Unknown Source)
at com.google.android.gms.internal.dx.bT(Unknown Source)
at com.google.android.gms.internal.dw$h.b(Unknown Source)
at com.google.android.gms.internal.dw$h.b(Unknown Source)
at com.google.android.gms.internal.dw$b.bR(Unknown Source)
at com.google.android.gms.internal.dw$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
This only seems to happen if I had already connected to the GoogleApiClient before and am connecting for a second time. Between the 2 calls I disconnect from the api client with the code below.
My guess is that this is a bug. Am I correct? Since I'm in the onConnected method, the GoogleApiClient should already be connected.
What can I do to get around it? Should I just wait for a while until the GoogleApiClient is really connected?
I am doing this in a service and here are the relevant bits:
when the service starts:
mMediaRouter.addCallback(mMediaRouteSelector, mediaCallback, MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
mediaCallback has this code:
#Override
public void onRouteAdded(MediaRouter router, RouteInfo route) {
super.onRouteAdded(router, route);
if (route.getDescription().equals("Chromecast")) {
...
mSelectedDevice = com.google.android.gms.cast.CastDevice.getFromBundle(route.getExtras());
...
castClientListener = new CastListener(context, apiClient);
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(mSelectedDevice, castClientListener);
...
apiClient.set(new GoogleApiClient.Builder(context).addApi(Cast.API, apiOptionsBuilder.build()).addConnectionCallbacks(connectionCallback).addOnConnectionFailedListener(new MediaConnectionFailedListener(context)).build());
apiClient.get().connect();
}
}
connectionCallback has this code:
#Override
public void onConnected(final Bundle arg0) {
...
Cast.CastApi.launchApplication(apiClient, UtilAutoCast.CHROMECAST_APP_ID, false).setResultCallback(connectionCallback);
...
}
The code above is the part where the crash happens.
And when I stop the service I run this code:
if (mMediaRouter != null) {
mMediaRouter.removeCallback(mediaCallback);
mMediaRouter = null;
}
if (apiClient != null) {
Cast.CastApi.stopApplication(apiClient);
if (apiClient.isConnected()) {
apiClient.disconnect();
apiClient = null;
}
}
Thanks in advance.
Google APIs for Android > GoogleApiClient
You should instantiate a client object in your Activity's onCreate(Bundle) method and then call connect() in onStart() and disconnect() in onStop(), regardless of the state.
The implementation of the GoogleApiClient appears designed for only a single instance. It's best to instantiate it only once in onCreate, then perform connections and disconnections using the single instance.
I would guess that only one GoogleApiClient can be actually be connected, but multiple instances are receiving the onConnected callback.
In your case it's probably fine to not call connect in onStart, but only in onRouteAdded.
I think this issue is very similar to Fatal Exception: java.lang.IllegalStateException GoogleApiClient is not connected yet
Have you declare following <meta> tag
<application ...>
...
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
...
</application>
I just forgot to write so may you also stuck with this reason.
Thank you.
From showcase app (Googlecast Github Sample CastHelloText-android ) receiver app is launched onRouteSelected (not onRouteAdded as you are doing in your code). I would try to change that. In case it does not work, I would add log lines in every method related to connection & session, and see what is happening.
Another tip: I have had crash with stopping the application (in case chromecast device is physically plugged out from power). Solution is to putCast.CastApi.stopApplication(apiClient); inside if (apiClient.isConnected()).
It seems like you are calling GoogleApiClient before it is connected
move this line in onCreate()
// First we need to check availability of play services
if (checkPlayServices()) {
// Building the GoogleApi client
//buildGoogleApiClient();
try {
mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
mGoogleApiClient.connect();
}catch (IllegalStateException e)
{
Log.e("IllegalStateException", e.toString());
}
createLocationRequest();
}
Hope it helps you.

Android Activity Recognition - Reconnecting following Disconnection

With Google Play Services' Activity Recognition, they recommend that if the service disconnects (which it might) then we should remove the client:
http://developer.android.com/training/location/activity-recognition.html
In some cases, Location Services may disconnect from the activity
recognition client before you call disconnect(). To handle this
situation, implement onDisconnected(). In this method, set the request
flag to indicate that a request is not in progress, and delete the
client
That's fine, but it gives no instructions for how to reconnect [safely]. I'm running this from a foreground service which needs to maintain activity recognition at all times, so following disconnection:
#Override
public void onDisconnected() {
mRecognitionEnabled = false;
mRequestInProgress = false;
mRecognitionClient = null;
//Re-initialise Activity Recognition if service is still running
if (sServiceRunning) {
triggerActivityRecognition();
}
}
I reinstantiate the client and reconnect:
private void triggerActivityRecognition() {
if (!mRequestInProgress ) {
mRequestInProgress = true;
mRecognitionClient = new ActivityRecognitionClient(this, this, this);
mRecognitionClient.connect();
}
}
But according to some of the bug reports I'm getting, there's an exception occurring as follows:
java.lang.NullPointerException
at com.google.android.gms.internal.bh.a(Unknown Source)
at com.google.android.gms.internal.k.f(Unknown Source)
at com.google.android.gms.internal.k$e.onServiceConnected(Unknown Source)
at com.google.android.gms.internal.l.a(Unknown Source)
at com.google.android.gms.internal.k.connect(Unknown Source)
at com.google.android.gms.location.ActivityRecognitionClient.connect(Unknown Source)
at com.myapp.MyService.triggerActivityRecognition(MyService.java:316)
at com.myapp.MyService.onDisconnected(MyService.java:407)
at com.google.android.gms.internal.k.A(Unknown Source)
at com.google.android.gms.internal.k$e.onServiceDisconnected(Unknown Source)
at com.google.android.gms.internal.l$a$a.onServiceDisconnected(Unknown Source)
The disconnection occurs rarely but results in the same stack trace every time.
So if this is being caused by Google Play Services, is there anything I can do to prevent it or is it a bug I need to log with Android?
This is what works for me:
Don't attempt the reconnect with the onDisconnect(), instead do nothing in the onDisconnect()
public void onDisconnected() {
//do nothing here
}
Simply use the client as before, but check if is connected
if (!mRecognitionClient.isConnected()) {
// Client is disconnected, reconnect now
mRecognitionClient.connect();
}
The PlayServices seems to reconnect very nicely.

Categories

Resources