NativeScript/NativeScript · error · Error
View not registered
Error message
View not registered
What it means
On Android, ListView reuses (recycles) native views. `_markViewUsed` looks up a native android.view.View in the internal `_realizedItems` map to move it from the available pool to in-use; if the view was never realized/registered by the ListView's adapter, the lookup returns nothing and this Error is thrown. It is called from `_getAvailableView`, so it surfaces during item view acquisition while scrolling or loading items.
Source
Thrown at packages/core/ui/list-view/index.android.ts:116
public _registerViewToTemplate(templateKey: string, nativeView: android.view.View, view: View) {
this._realizedItems.set(nativeView, {
view,
templateKey,
});
if (!this._realizedTemplates.has(templateKey)) {
this._realizedTemplates.set(templateKey, new Map());
}
this._realizedTemplates.get(templateKey).set(nativeView, view);
this._ensureAvailableViews(templateKey);
const availableViews = this._availableViews.get(templateKey);
availableViews.add(nativeView);
}
public _markViewUsed(nativeView: android.view.View) {
const viewData = this._realizedItems.get(nativeView);
if (!viewData) {
throw new Error('View not registered');
}
this._ensureAvailableViews(viewData.templateKey);
this._availableViews.get(viewData.templateKey).delete(nativeView);
}
public _markViewUnused(nativeView: android.view.View) {
const viewData = this._realizedItems.get(nativeView);
if (!viewData) {
throw new Error('View not registered');
}
this._ensureAvailableViews(viewData.templateKey);
this._availableViews.get(viewData.templateKey).add(nativeView);
}
public _getKeyFromView(nativeView: android.view.View) {
return this._realizedItems.get(nativeView).templateKey;
}
public _hasAvailableView(templateKey: string) {
this._ensureAvailableViews(templateKey);
return this._availableViews.get(templateKey).size > 0;View on GitHub (pinned to 6800aefa65)
Solutions
- Do not create or recycle item views manually on Android — let the ListView adapter realize them so they get registered in `_realizedItems`.
- Update to a recent @nativescript/core version; several ListView recycling fixes have landed upstream.
- If you have a custom adapter override, ensure every view it returns is registered via the base class realization flow (i.e. call super / go through the standard template realization).
- Avoid sharing the same item view instances between multiple ListView instances or templates.
Defensive patterns
Strategy: try-catch
Validate before calling
let view: android.view.View;
try {
view = listView._getAvailableView(templateKey);
} catch (e) {
if (e.message === 'View not registered') {
view = null; // fall back to normal realization
} else {
throw e;
}
} Type guard
const isRegistered = (lv: any, v: android.view.View): boolean => lv._realizedItems && lv._realizedItems.has(v);
Try / catch
try {
this._markViewUsed(nativeView);
} catch (e) {
if (e.message === 'View not registered') {
// re-realize through the standard adapter path instead of reusing
return this.rematerializeItemView(nativeView);
}
throw e;
} Prevention
- Never bypass the ListView adapter's view realization path on Android.
- Don't share native item views across ListView instances, templates, or template selectors.
- Keep @nativescript/core updated; recycling bugs are regularly patched.
- Test template-selector changes and fast scrolling, the most common repro triggers.
When it happens
Trigger: A native view reaches `_getAvailableView` without having gone through the adapter's realization path — e.g. custom adapter overrides that bypass `_realizedItems` registration, view pool manipulation, or item views created outside `ListView`'s `_onLoadingItem`/realization flow.
Common situations: Subclassing or patching the Android ListView adapter and recycling views manually; native plugin interop that reuses views across ListView instances; race conditions during fast scrolling with itemTemplateSelector changes; fragment/activity recreation reusing stale native views.
Related errors
- Application.android already initialized.
- Failed to retrieve native Android Application object. If you
- Application is already started.
- Cannot find android activity.
- Cannot find android activity callbacks.
AI-assisted analysis of NativeScript/NativeScript@6800aefa65 (2026-08-30).
Data as JSON: /api/errors/3528d1dc690d7540.
Report an issue: GitHub.