Environment
- @nativescript/core 9.1.2
- @nativescript/android 9.1.1
- @nativescript/vite 8.0.17
- Android 15 emulator (API 35)
Repro
class ReproView extends android.view.View {
override onDraw(canvas: android.graphics.Canvas): void {
console.log('onDraw')
}
}
const v = new ReproView(Utils.android.getApplicationContext())
console.log(v.getClass().getName())
const content = Application.android.foregroundActivity.findViewById(android.R.id.content)
content.addView(v, new android.view.ViewGroup.LayoutParams(60, 60))
Expected
getClass().getName() returns a generated proxy subclass (e.g. com.tns.gen.android.view.View_...), and onDraw dispatches into the JS override — the same outcome as (android.view.View as any).extend({ onDraw ... }), which produces a View_ts_* class and works correctly on the same stack.
Actual
getClass().getName() returns android.view.View — a plain superclass instance with no generated subclass. All JS overrides (onDraw, onMeasure, draw, onAttachedToWindow) are silently dead: the view mounts, lays out, and never calls them.
Notes
- The failure is silent — nothing in logcat indicates proxy generation was skipped. We only found it because a custom-draw view (an SVG renderer) mounted with correct bounds but painted nothing.
__extends-compiled classes DO generate proxies at runtime on this stack (logcat shows Class X not precompiled; generating at runtime for framework classes and they dispatch correctly). It looks like the vite dev module path serves real ES class syntax that bypasses whichever mechanism intercepts Java-class extension — either the __extends hook or V8-level extends interception.
- Verified via
run-as file probes from inside the app: onDraw never ran, while getClass().getName() reported the superclass. After switching the same view to View.extend({...}), getClass().getName() reported a generated View_ts_* subclass and onDraw fired.
Environment
Repro
Expected
getClass().getName()returns a generated proxy subclass (e.g.com.tns.gen.android.view.View_...), andonDrawdispatches into the JS override — the same outcome as(android.view.View as any).extend({ onDraw ... }), which produces aView_ts_*class and works correctly on the same stack.Actual
getClass().getName()returnsandroid.view.View— a plain superclass instance with no generated subclass. All JS overrides (onDraw,onMeasure,draw,onAttachedToWindow) are silently dead: the view mounts, lays out, and never calls them.Notes
__extends-compiled classes DO generate proxies at runtime on this stack (logcat showsClass X not precompiled; generating at runtimefor framework classes and they dispatch correctly). It looks like the vite dev module path serves real ES class syntax that bypasses whichever mechanism intercepts Java-class extension — either the__extendshook or V8-levelextendsinterception.run-asfile probes from inside the app:onDrawnever ran, whilegetClass().getName()reported the superclass. After switching the same view toView.extend({...}),getClass().getName()reported a generatedView_ts_*subclass andonDrawfired.