Android 'Wrong state class, expecting View State...'
See original GitHub issuePlease, provide the details below:
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
Yes
Tell us about the problem
Only in Android, the app crashes when I have 2 different elements (in my case, a MapView
which comes from the nativescript-google-maps-sdk
plugin, and a ListView
) in the same row and column in a Page
(A) with a GridLayout
, then I navigate to a different Page
(B), then I navigate back to A.
Which platform does your issue occur on?
Android, only found on version 4.4.4.
Please provide the following version numbers that your issue occurs with:
- CLI: 2.5.0
- Cross-platform modules: 2.5.0
- Runtime(s): tns-android: 2.5.0, tns-ios: 2.5.0
- Plugin(s): nativescript-google-maps-sdk: 1.4.3
Please tell us how to recreate the issue in as much detail as possible.
tns run android
using Android 4.4.4 device or emulator.- Tap any list item or tap the
Go to detail
button. - Navigate back (by pressing the hardware ‘back’ button, or the navigation button).
- App crashes. The console outputs nothing, but the ErrorActivity produces this:
An uncaught Exception occurred on “main” thread. java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view’s id is id/0x2. Make sure other views do not use the same id. at android.view.View.onRestoreInstanceState(View.java:13903)
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
Project is here.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
I was able to fix this issue (I think) by adding the following:
app/App_Resources/Andorid/values/ids.xml
:map.component.html
:map.component.ts
:The issue could have been caused by this, but I’m not certain:
tns-core-modules/ui/list-view/list-view.android.ts
:So far, I haven’t seen any repercussions from manually setting the
id
in my project.Updated project and resolution is here.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.