ArrayIndexOutOfBounds LifecycleRegistry.popParentState - android

I came across an exception on which I do not have a clue on how to fix it. Here is the stacktrace:
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.remove(ArrayList.java:480)
at android.arch.lifecycle.LifecycleRegistry.popParentState(LifecycleRegistry.java:194)
at android.arch.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:293)
at android.arch.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:332)
at android.arch.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:137)
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:123)
at android.arch.lifecycle.ReportFragment.dispatch(ReportFragment.java:121)
at android.arch.lifecycle.ReportFragment.onStart(ReportFragment.java:81)
at android.app.Fragment.performStart(Fragment.java:2378)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1027)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:2048)
at android.app.FragmentController.dispatchStart(FragmentController.java:188)
at android.app.Activity.performStart(Activity.java:6978)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2937)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
I'm using android.arch.lifecycle:extensions:1.1.1.
UPDATE
I got more informations.
This is happening when I start an activity for result from within a Fragment by calling Fragment.startActivityForResult(). This Fragment is in "strange" place. Here it is the structure of its holding Activity
- HoldingActivity
-- HoldingFragment
--- FragmentPagerAdapter
---- MyFragment // This is where I call the startActivityForResult
Another point that might help is that every level of the HoldingActivity is using ViewDataBinding.setLifecycleOwner(this) and they all have a ViewModel attached to it.
The started Avtivity is hosting a Fragment and they also both use ViewDataBinding.setLifecycleOwner(this) and have a ViewModel.
Let me know if anything else could help resolve this issue, thanks.

Related

Android SurfaceView gets disconnecting from surface, reason connectToSurface(reconnect) using Compose's AndoridView

I am playing around with jetpack compose and surface view and I often land into this issue where in the surfaceview gets randomly disconnected from surface. I've added the stack trace for reference. Can someone help me to fix this?
java.lang.IllegalArgumentException: detached
at MobilePlayerViewModel$createSurfaceViewOnAttachStateChangeListener$1.onViewDetachedFromWindow(MobilePlayerViewModel.kt:356)
at android.view.View.dispatchDetachedFromWindow(View.java:21362)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3949)
at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5785)
at androidx.compose.ui.viewinterop.AndroidViewHolder.setView$ui_release(AndroidViewHolder.android.kt:95)
at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:310)
at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:307)
at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:420)
at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
at androidx.compose.ui.node.LayoutNode.onChildRemoved(LayoutNode.kt:314)
at androidx.compose.ui.node.LayoutNode.removeAt$ui_release(LayoutNode.kt:288)
at androidx.compose.ui.node.UiApplier.remove(UiApplier.android.kt:35)
at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:808)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:839)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:995)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
at androidx.compose.runtime.Recomposer$HotReloadable.clearContent(Recomposer.kt:385)
at androidx.compose.runtime.Recomposer$RecomposerInfoImpl.saveStateAndDisposeForHotReload(Recomposer.kt:369)
at androidx.compose.runtime.Recomposer$Companion.saveStateAndDisposeForHotReload$runtime_release(Recomposer.kt:1285)
at androidx.compose.runtime.HotReloader$Companion.saveStateAndDispose(Composition.kt:1136)
at dalvik.system.VMDebug.nativeAttachAgent(Native Method)
at dalvik.system.VMDebug.attachAgent(VMDebug.java:656)
at android.app.ActivityThread.attemptAttachAgent(ActivityThread.java:4220)
at android.app.ActivityThread.handleAttachAgent(ActivityThread.java:4230)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2296)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Sometimes get android.content.res.Resources$NotFoundException

We're debugging a crash in a Cordova app that seems to happen on launch / foregrounding, after the app was backgrounded for a moderate amount of time and has been to some extent killed by the OS.
At the time of the crash the app is attempting to show a native dialog fragment for Fingerprint Authentication. For some reason in this case the resources for this fragment cannot be found.
It's been reported for Android 6 and 7, on older and newer devices.
java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.koho/ca.koho.Koho}: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2421)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:174)
at android.app.ActivityThread.main(ActivityThread.java:5440)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1437)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2887)
at android.content.res.Resources.getLayout(Resources.java:1251)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at com.cordova.plugin.android.fingerprintauth.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:85)
at android.app.Fragment.performCreateView(Fragment.java:2220)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130)
at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1953)
at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:152)
at android.app.Activity.performCreateCommon(Activity.java:6279)
at android.app.Activity.performCreate(Activity.java:6287)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2374)
... 9 more
Here's the problematic bit of code, from the DialogFragment's onCreateView:
int fingerprint_dialog_container_id = getResources()
.getIdentifier("fingerprint_dialog_container", "layout",
FingerprintAuth.packageName);
View v = inflater.inflate(fingerprint_dialog_container_id, container, false);
When the crash happens, getIdentifier(...) is for some reason returning 0. Most of the time the actual identifier is returned.
I have not found a way to reproduce the crash, and advice to enable developer options like 'Don't keep activities' and 'Background process limit' had did not help.
Thanks for any help.

Facebook ProfilePictureView causing FAILED BINDER TRANSACTION

Been pulling my hair out trying to figure out why my app keeps crashing, I've nailed it down to having this in my main activities layout XML.
<com.facebook.login.widget.ProfilePictureView
android:id="#+id/pp"
android:layout_gravity="center"
android:layout_height="match_parent"
android:layout_width="match_parent">
</com.facebook.login.widget.ProfilePictureView>
Whenever I have this in my main activity layout, and I try to create any new intents (new activities, facebook sign in or requesting permissions) My app crashed with a FAILED BINDER TRANSACTION and TransactionTooLargeException.
This continues to happen when I remove the profile picture code in the activity class. It seems to be the view appearing that's casing this but I cannot think why.
This occurs not on my main testign device, but on all emulators and other devices Ive tried.
stacktrace
03-13 15:29:21.347 28962-28962/uk.co.claytapp.taggerbath E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1443592)
03-13 15:29:21.348 28962-28962/uk.co.claytapp.taggerbath D/AndroidRuntime: Shutting down VM
03-13 15:29:21.348 28962-28962/uk.co.claytapp.taggerbath E/AndroidRuntime: FATAL EXCEPTION: main
Process: uk.co.claytapp.taggerbath, PID: 28962
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1443592 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3752)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.os.TransactionTooLargeException: data parcel size 1443592 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3606)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3744)
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
This most likely happens in the onSaveInstanceState(Bundle outState) method of the activity you are navigating away from.
To fix it, add android:saveEnabled="false" to your ProfilePictureView like so:
<com.facebook.login.widget.ProfilePictureView
android:id="#+id/profilePicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:saveEnabled="false"
facebook:com_facebook_preset_size="normal" />
This will prevent Android to call ProfilePictureView's own onSaveInstanceState method (the view hierarchy is stored by the Activity anyway so it won't hurt).

illegal state exception from startactivity

Hi guys I am getting the following exception
ERR-5e1e9c7f83ba94b45017220ad632c|StackTrace:java.lang.IllegalStateException: Fragment Gallery{d6a81c0} not attached to Activity
--------- Stack trace ---------
android.support.v4.app.Fragment.startActivity(Fragment.java:914)
mypackage.Gallery$openReceiptImage.onPostExecute(Gallery.java:1604)
mypackage.Gallery$openReceiptImage.onPostExecute(Gallery.java:1424)
android.os.AsyncTask.finish(AsyncTask.java:651)
android.os.AsyncTask.access$500(AsyncTask.java:180)
android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:148) android.app.ActivityThread.main(ActivityThread.java:7325) java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
------------------------------- --------- Cause --------- -------------------------------
My code is as follows
Intent fullimage=new Intent(mContext, Preview.class);
startActivity(fullimage);
Here mContext is Context and I am calling this from Fragment. Preview is Activity. I beleieve these informations are enough. And also I am not getting this issue always.
Can anyone tell me what could be the reason for this issue.
Thanks in Advance.
Issue is fixed
if(isAdded){ }
Is used to check whether that fragment is attached to Activity or not

Android strange ClassCastException

A few days ago we started to receive some crash reports from users using our app, but the stracktrace is really strange. It happens only on Samsung G900f (S5) and I can't reproduce it and decide to post a question here.
The stacktrace shows this:
Caused by java.lang.ClassCastException: android.support.design.widget.CollapsingToolbarLayout cannot be cast to android.support.design.widget.CollapsingToolbarLayout
at com.packageName.profile.ProfileFragment.onViewCreated(SourceFile:423)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1086)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1248)
at android.support.v4.app.BackStackRecord.run(SourceFile:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(SourceFile:1613)
at android.support.v4.app.FragmentController.execPendingActions(SourceFile:330)
at android.support.v4.app.FragmentActivity.onStart(SourceFile:547)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)
at android.app.Activity.performStart(Activity.java:6258)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
It is a Fragment which contains CollapsingToolbarLayout with initialization and use all correct, but not sure why this happens.
We got some other ClassCastExceptions with different classes from the same device. For example:
Caused by java.lang.ClassCastException:
com.packageName.model.VideoMeta cannot be cast to
com.packageName.model.VideoMeta
where VideoMeta is a class which implements Parcelable and this exception occurs in class Video which implements Parcelable too:
private Video(Parcel in) {
id = in.readLong();
postId = in.readString();
url = in.readString();
thumb = in.readString();
meta = (VideoMeta) in.readValue(VideoMeta.class.getClassLoader());
}
But that's not the end...
Caused by java.lang.ClassCastException:
android.support.design.widget.AppBarLayout$LayoutParams cannot be cast to
android.support.design.widget.AppBarLayout$LayoutParams
I have no idea what can cause this exception and why it's happening, that's why posting it here.
Thanks in advance for any kind of help or suggestions!

Categories

Resources