Yes
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.
Android, only found on version 4.4.4.
tns run android using Android 4.4.4 device or emulator.Go to detail button.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)
Project is here.
I even tried alleviating the problem by adding
ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="my_map_view" type="id" />
<item name="my_list_view" type="id" />
</resources>
and
<MapView #mapView row="1" (mapReady)="onMapReady($event)" android.id="R.id.my_map_view"></MapView>
<ListView row="1" [items]="myItems" (itemTap)="onItemTapped($event)"
android.id="R.id.my_list_view">
Hi @EricRobertBrewer,
Thank you for reporting this issue.
I confirm this is a real issue for Android while using nativescript-google-maps-sdk and ListView. This problem could be reproduced, when navigating back to a page, with Google maps.
This behavior has been reproduced also on non NativeScirpt Angular 2 project. I am attaching a link to sample project, where the problem could be reproduced.
I'm also having this issue as well. Only occurs when listview is on html page that belongs to map component. Solution for anybody having this problem temporarily...put listview elsewhere or remove it until this is fixed.
I was able to fix this issue (I think) by adding the following:
app/App_Resources/Andorid/values/ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="my_list_view" type="id" />
</resources>
map.component.html:
<ListView row="1" [items]="myItems" (itemTap)="onItemTapped($event)" (loaded)="onListViewLoaded($event)">
map.component.ts:
onListViewLoaded(event) {
if (event.object.android) {
event.object.android.setId(org.nativescript.mapview.R.id.my_list_view);
}
}
The issue could have been caused by this, but I'm not certain:
tns-core-modules/ui/list-view/list-view.android.ts:
public _createNativeView() {
...
if (this._androidViewId < 0) {
this._androidViewId = android.view.View.generateViewId();
}
this._android.setId(this._androidViewId);
...
}
So far, I haven't seen any repercussions from manually setting the id in my project.
Updated project and resolution is here.
Thnx @EricRobertBrewer i've come across this problem and this helped me fix it.
I'm using id's for appium testing, any update on how to set Id's on elements hybrid xml for android? is it at all possible
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.
Most helpful comment
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
idin my project.Updated project and resolution is here.