Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android O Beta - java.lang.IllegalStateException: Handling non empty state of parent class is not implemented #477

Open
NLLAPPS opened this Issue Jun 4, 2017 · 39 comments

Comments

Projects
None yet
@NLLAPPS
Copy link

commented Jun 4, 2017

Is this project still maintained?
Every now and then I get above error on Android O Beta. I guess it is related the OS but just heads up

Stack trace:

Java.lang.IllegalStateException: Handling non empty state of parent class is not implemented
at se.emilsjolander.stickylistheaders.StickyListHeadersListView.onSaveInstanceState(StickyListHeadersListView.java:1098)
at android.view.View.dispatchSaveInstanceState(View.java:17157)
at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3668)
at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3674)
at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3674)
at android.view.View.saveHierarchyState(View.java:17140)

@sandy-8925

This comment has been minimized.

Copy link

commented Jun 8, 2017

I can confirm, this error happens only on Android O for us, and seems to happen only on Nexus/Pixel devices.

Edit: Was mislead by API level 25 in crash reports, looks like Android O reported API level 25 for a while.

@NLLAPPS

This comment has been minimized.

Copy link
Author

commented Jun 9, 2017

@mtotschnig

This comment has been minimized.

Copy link
Contributor

commented Jun 9, 2017

With O and maybe earlier, the assumption that StickyListHeaderListView class relies on (that the super class does not have any state of its own to safe) no longer necessarily holds true. On my fork I tried to implement proper handling of this new situation: mtotschnig@c9f9a44

@chrisonline

This comment has been minimized.

Copy link

commented Jun 12, 2017

@mtotschnig Great, thanks. Do you have a compile url for gradle for your fork?
Because this library seems is discontinued and won't get any fix.

@mtotschnig

This comment has been minimized.

Copy link
Contributor

commented Jun 12, 2017

@NLLAPPS

This comment has been minimized.

Copy link
Author

commented Jun 26, 2017

@mtotschnig There might be an issue with your implementation. I had a crash in the app, unrelated to your code but trace kept showing me your implementation about saved state. I was not able to capture it.
I will post details if I can recreate it

@NLLAPPS

This comment has been minimized.

Copy link
Author

commented Jun 26, 2017

Ah! Error exactly as @nvquockhtn posted at mtotschnig@c9f9a44

@Cylix

This comment has been minimized.

Copy link

commented Jun 26, 2017

I got this issue from crashlytics too (Java.lang.IllegalStateException: Handling non empty state of parent class is not implemented).

Did you find a way to reproduce it?
I setup Android O on a virtual device on Android Studio (nexus pixel xl) but everything works fine.
If it happens in the onSaveInstance, I expect it to happen on some configuration change, but no way to reproduce it (I tried to rotate, lock, switch from one app to another, whatever, everything works fine).

I'd like to at least be able to reproduce it so that I can be sure that the fix works.
So, if you have any clue about how to trigger the exception, I'd be suuuuper glad!

@sandy-8925

This comment has been minimized.

Copy link

commented Jun 26, 2017

@NLLAPPS

This comment has been minimized.

Copy link
Author

commented Jun 26, 2017

I was not able to reproduce it on Nexus 5x with latest Android beta but got many crash reports from Nexus 6P when launching a different activity from the activity with StickyHeaders. I wonder if it is related to device.

@Sloy

This comment has been minimized.

Copy link

commented Jun 26, 2017

I didn't reproduce it with a virtual device either. But with a physical Nexus 6P it happened all the time.

@Cylix

This comment has been minimized.

Copy link

commented Jun 26, 2017

Thanks for your replies!
Yeah, unfortunately, I do not have nexus 6P or pixel, only a Nexus 6 but there is no way to install Android O on it apparently, so I guess I have no way, for now, to reproduce on my side.
Thank again for the quick replies :)

mtotschnig referenced this issue in mtotschnig/StickyListHeaders Jun 26, 2017

at least with O, we no longer can rely on superstate being empty. Imp…
…lement proper parceling of both super and wrapped state
@mtotschnig

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2017

By the way, you can increase the probability of reproducing the crash by setting "Don't keep activities" in the systems' developer settings.

@crucibond

This comment has been minimized.

Copy link

commented Sep 10, 2017

Hi, I am facing similar issue and were anyone able to solve this?

java.lang.IllegalStateException:
at se.emilsjolander.stickylistheaders.StickyListHeadersListView.onSaveInstanceState (StickyListHeadersListView.java:1029)

@mtotschnig

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2017

It is solved in https://github.com/mtotschnig/StickyListHeaders/releases/tag/2.7.1 .
Use it via Jitpack
compile 'com.github.mtotschnig:StickyListHeaders:2.7.1'

@madhacked

This comment has been minimized.

Copy link

commented Sep 12, 2017

@emilsjolander any plans to bring in @mtotschnig fixes? I'd prefer not to add Jitpack to my project! Thanks!

@Cylix

This comment has been minimized.

Copy link

commented Sep 12, 2017

@madhacked this project is 100% not maintained anymore, the last commit is dated from 2015. I don't think you should expect any plans.
Best case would be someone forking this repo and maintaining the fork.

@edisonw

This comment has been minimized.

Copy link

commented Sep 13, 2017

fyi @madhacked and those who do not want to use jitpack or the additional support library dependency:

I have compiled the aar off master + 1 proper fix commit (edisonw@3dd88a2)

The download link is here:

https://github.com/edisonw/StickyListHeaders/blob/master/release-2.7.2.aar

Everyone feel free to rename and download it locally if needed.

Note the correct way to use an aar file, if your file is inside /projectRoot/app/libs/sticky-list-headers.aar,

You need to declare this in your root dependency configuration:


        flatDir {
            dirs project(':app').file('libs')
        }

And then you can use it as
compile(name:'sticky-list-headers', ext:'aar')

dbahat added a commit to dbahat/conventions that referenced this issue Sep 29, 2017

Bug fix - crash on Android 8 in emilsjolander oss
Root cause - wrong assumptions regarding onSavedInstanceState behavior. See emilsjolander/StickyListHeaders#477.
Fix: Using a private fork by mtotschnig from JitPack with a fix.
@jungc

This comment has been minimized.

Copy link

commented Oct 10, 2017

Hey guys,

@mtotschnig's personal forks had changes other than the problem addressed above.
I've created a fork with his solution to the problem without any other changes.
PR: jungc#1
It has been merged to master on my fork
Also, I changed the version number to "2.7.1-FORK" in case this project ever gets maintained again.

Where to get the .aar file for your project :)
https://github.com/jungc/StickyListHeaders/releases/tag/2.7.1-FORK

NOTE:
1. This change comes from Groupon.
2. We won't maintain it.

@haemi

This comment has been minimized.

Copy link

commented Oct 24, 2017

@jungc how can I install/use this fork?

@dapda

This comment has been minimized.

Copy link

commented Oct 24, 2017

@jungc

This comment has been minimized.

Copy link

commented Oct 25, 2017

@haemi thanks for pointing that out. I've uploaded the .aar file here https://github.com/jungc/StickyListHeaders/releases/tag/2.7.1-FORK

@haemi

This comment has been minimized.

Copy link

commented Oct 31, 2017

@jungc thanks, I did that but I get failed to resolve: se.emilsjolander:stickylistheaders:stickylistheaders:

I updated my app-build.gradle:

repositories {
    maven { url "${rootDir}/local_repos" }
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    google()
}
implementation "se.emilsjolander:stickylistheaders:stickylistheaders:2.7.1-FORK@aar"

file is here:

local_repos/se/emilsjolander/stickylistheaders/2.7.1-FORK/stickylistheaders-2.7.1-FORK.aar
@haemi

This comment has been minimized.

Copy link

commented Nov 7, 2017

@jungc help pleeeeease...

@jungc

This comment has been minimized.

Copy link

commented Nov 14, 2017

@haemi @Sloy sorry about the delay. It looks like I made a typo with the previous release draft. It took me awhile to notice but it should be:
implementation "se.emilsjolander:stickylistheaders:2.7.1-FORK@aar" :)
<group id>:<artifact id>:<version>@aar^

@brianguertin

This comment has been minimized.

Copy link

commented Nov 17, 2017

Hey guys, you don't have to use a fork; the extra saved state comes from the autofill framework.

Disable autofill on the StickyListHeadersListView, and it will work fine.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  myList.setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
}

Of course, if you WANT autofill in your list view, then this workaround is not for you :)

@CsabaZz

This comment has been minimized.

Copy link

commented Nov 23, 2017

@brianguertin thanks, it's working perfectly!

@ykphuah

This comment has been minimized.

Copy link

commented Nov 25, 2017

@brianguertin Thanks, it works. Strange that I have two list with sticky headers and this issue only happen to one of them. I tried to compare the two and they seems exactly the same. Only one of them need your "fix".

Thanks again!

Tougee added a commit to Tougee/country-picker-android that referenced this issue Jan 2, 2018

@prince3156

This comment has been minimized.

Copy link

commented Jan 4, 2018

Android 25 the same issue occured.

@kohterachai

This comment has been minimized.

Copy link

commented Jan 15, 2018

#420 Xposed v89 SDK26 crash on module download page

rovo89 added a commit to rovo89/XposedInstaller that referenced this issue Jan 18, 2018

mokeeopensource pushed a commit to MoKee/android_packages_apps_XposedInstaller that referenced this issue Jan 18, 2018

Fix crash on Oreo
Fixes rovo89#420.
See also emilsjolander/StickyListHeaders#477.

Change-Id: I3545ab04f8587233f2e1e2ddd767c37dba40d288
@kohterachai

This comment has been minimized.

Copy link

commented Feb 2, 2018

@NLLAPPS

Sent from my A37f using FastHub

@HoriaGoran

This comment has been minimized.

Copy link

commented Feb 19, 2018

I am extending StickyListHeadersListView:

public class CustomStickyListHeadersListView extends StickyListHeadersListView {
....
    @Override
    public void setImportantForAutofill(int mode) {
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            super.setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
       }
    }
....
}

this does not work for me, still crashing...

@peshkira

This comment has been minimized.

Copy link

commented Feb 19, 2018

@HoriaGoran Do you call your method then? You have just overriden it, but you probably never call it?

@HoriaGoran

This comment has been minimized.

Copy link

commented Feb 20, 2018

I did call it.
If you look at the View.java, onSaveInstanceState() it has this condition:

if (mStartActivityRequestWho != null || isAutofilled()
|| mAutofillViewId > LAST_APP_AUTOFILL_ID) {

So even if isAutofilled() will be false with the proposed fix, its is enough for 1 of the other 2 checks to be true and to return a non empty state for the exception to be thrown.
I think this is the reason why the fix with setImportantForAutofill didn't work in my case.
I fixed this by importing one of the forked libs mentioned in the thread.

DVDAndroid added a commit to DVDAndroid/XposedInstaller that referenced this issue Feb 20, 2018

Fix crash on Oreo
Fixes rovo89#420.
See also emilsjolander/StickyListHeaders#477.

(cherry picked from commit 847f96e)
@SolveBugs

This comment has been minimized.

Copy link

commented May 14, 2018

@brianguertin Excuse me, can say in detail how to use the code you have shown above,thanks a lot.

@SolveBugs

This comment has been minimized.

Copy link

commented May 14, 2018

@brianguertin I have already solved, thanks again。

@hendrawd

This comment has been minimized.

Copy link

commented May 28, 2018

autofill framework breaks everything :(

@hendrawd

This comment has been minimized.

Copy link

commented May 28, 2018

@mtotschnig I tried your solution, but there is an error when running the app.
Program type already present: se.emilsjolander.stickylistheaders.CheckableWrapperView
Do you know how to fix it except disabling R8 and D8?

@hendrawd

This comment has been minimized.

Copy link

commented May 28, 2018

Looks like, one of my modules also using this library, so I had to change both of my module-level build.gradle and app-level build.gradle, clean and rebuild to make it work.

tal-s added a commit to dbahat/conventions that referenced this issue Jul 21, 2018

Bug fix - crash on Android 8 in emilsjolander oss
Root cause - wrong assumptions regarding onSavedInstanceState behavior. See emilsjolander/StickyListHeaders#477.
Fix: Using a private fork by mtotschnig from JitPack with a fix.

solohsu pushed a commit to solohsu/XposedInstaller that referenced this issue Feb 22, 2019

Fix crash on Oreo
Fixes rovo89#420.
See also emilsjolander/StickyListHeaders#477.

(cherry picked from commit 847f96e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.