René's URL Explorer Experiment


Title: Static binding names never match at runtime since 9.0.0 — every `extend()` falls back to runtime dex generation · Issue #2024 · NativeScript/android · GitHub

Open Graph Title: Static binding names never match at runtime since 9.0.0 — every `extend()` falls back to runtime dex generation · Issue #2024 · NativeScript/android

X Title: Static binding names never match at runtime since 9.0.0 — every `extend()` falls back to runtime dex generation · Issue #2024 · NativeScript/android

Description: Since 9.0.0, the class name the static binding generator emits and the class name the runtime asks for are different, so DexFactory.resolveClass never finds a pre-generated binding and generates a proxy dex at runtime for every anonymous...

Open Graph Description: Since 9.0.0, the class name the static binding generator emits and the class name the runtime asks for are different, so DexFactory.resolveClass never finds a pre-generated binding and generates a ...

X Description: Since 9.0.0, the class name the static binding generator emits and the class name the runtime asks for are different, so DexFactory.resolveClass never finds a pre-generated binding and generates a ...

Opengraph URL: https://github.com/NativeScript/android/issues/2024

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Static binding names never match at runtime since 9.0.0 — every `extend()` falls back to runtime dex generation","articleBody":"Since `9.0.0`, the class name the **static binding generator** emits and the class name the **runtime** asks for are different, so `DexFactory.resolveClass` never finds a pre-generated binding and generates a proxy dex at runtime for *every* anonymous `extend()` in the app — including the ~60 that `@nativescript/core` itself performs (gesture listeners, click listeners, adapters, fragments, …).\n\nIt is invisible on healthy devices (it \"only\" costs startup time), but it turns a whole class of storage/IO/concurrency failures in `DexFactory` into hard failures of the app. It also means the pre-generated bindings that ship in every APK/AAB are dead weight.\n\nTwo independent defects stack up. The first one alone is enough to break the match.\n\n---\n\n## Defect 1 — the SBG appends an MD5 the runtime never computes\n\n[#1836](https://github.com/NativeScript/android/pull/1836) (`feat: ES modules (ESM) support`, released in `9.0.0`) changed the naming in `Generator.java`:\n\n```diff\n-        // name of the class: last portion of the full file name + line + column + variable name\n-        String[] lastFilePathPart = dataRow.getFile().split(\"_\");\n-        name += lastFilePathPart[lastFilePathPart.length - 1] + \"_\" + dataRow.getLine() + \"_\" + dataRow.getColumn() + \"_\" + dataRow.getNewClassName();\n+        // Generate a unique identifier that prevents naming collisions\n+        // especially with .mjs files and complex structures\n+        String fileIdentifier = generateUniqueFileIdentifier(dataRow.getFile());\n+        name += fileIdentifier + \"_\" + dataRow.getLine() + \"_\" + dataRow.getColumn() + \"_\" + dataRow.getNewClassName();\n```\n\n`generateUniqueFileIdentifier` returns `\u003clast up-to-3 \"_\"-segments>_\u003cfirst 3 bytes of md5(filePath) as hex>`.\n\nThe runtime side of the same name — `MetadataNode::GetExtendLocation` in `MetadataNode.cpp` — still does what the old SBG line did:\n\n```cpp\nUtil::SplitString(fullPathToFile, \"_\", pathParts);\nstd::string lastPathPart = pathParts.back();\nfullPathToFile = lastPathPart;\n```\n\nThere is no MD5 anywhere in the runtime. `#1836` did not touch `MetadataNode.cpp` (see the PR's file list), and `git log` on `test-app/runtime/src/main/cpp/MetadataNode.cpp` shows no commit between `2025-02-20` and `2026-08-03`. So from `9.0.0` on, the SBG emits `…_vendor_7c3613_…` while the runtime asks for `…_vendor_…`.\n\n## Defect 2 — the runtime strips 3 characters assuming `.js`, but bundles are `.mjs`\n\nSame function, `9.0.4` / `9.0.5`:\n\n```cpp\nint strToTakeLen = (srcFileName.length() - startIndex - 3); // 3 refers to .js at the end of file name\nfullPathToFile = srcFileName.substr(startIndex, strToTakeLen);\n\nstd::replace(fullPathToFile.begin(), fullPathToFile.end(), '/', '_');\nstd::replace(fullPathToFile.begin(), fullPathToFile.end(), '.', '_');\n…\nstd::vector\u003cstd::string> pathParts;\nUtil::SplitString(fullPathToFile, \"_\", pathParts);\nstd::string lastPathPart = pathParts.back();\n```\n\nWith `file:///data/data/\u003cpkg>/files/app/vendor.mjs`, cutting 3 chars leaves `app/vendor.` → `app_vendor_` → `SplitString` yields `[\"app\", \"vendor\", \"\"]` → `back()` is the **empty string**. So the file component is not merely different, it is empty.\n\nThis half is already fixed on `main` (commit `bce66986c7`, [#1965](https://github.com/NativeScript/android/pull/1965)) — `.mjs` is stripped and the last *non-empty* part is taken. **But that fix does not close the gap**: I checked `v9.1.0-rc.0`, where the runtime now yields `vendor` and `Generator.java` still yields `vendor_7c3613`. Defect 1 is untouched on `main`.\n\n---\n\n## Reproduction / evidence\n\nNativeScript 9 app (`@nativescript/core` 9.0.20, `@nativescript/android` 9.0.4), release AAB.\n\nThe SBG emits, and the AAB ships:\n\n```\n$ strings base/dex/*.dex | grep TapAndDoubleTapGestureListenerImpl\nLcom/tns/gen/android/view/GestureDetector_SimpleOnGestureListener_vendor_7c3613_2_1631471_TapAndDoubleTapGestureListenerImpl;\n```\n\n`sbg-bindings.txt` row (file component is `vendor`, line 2, column 1631471):\n\n```\nandroid.view.GestureDetector.SimpleOnGestureListener*vendor*2*1631471*TapAndDoubleTapGestureListenerImpl*onSingleTapUp,onDown,onLongPress,_handleSingleTap,_handleDoubleTap,DoubleTapTimeout***\n```\n\n`md5(\"vendor\") = 7c3613dba5171cb6027c67835dd3b9d4` → `7c3613`, confirming where the suffix comes from.\n\nThe runtime asks for the same line/column with an empty file component, fails, and generates the dex at runtime — here is a user-facing crash from a device where that generation failed:\n\n```\nCalling js method onCreateView failed\nError: java.lang.ClassNotFoundException: Didn't find class\n\"android.view.GestureDetector_SimpleOnGestureListener__2_1631471_TapAndDoubleTapGestureListenerImpl\"\non path: DexPathList[[zip file \"/data/user/0/\u003cpkg>/code_cache/secondary-dexes/android.view.GestureDetector_SimpleOnGestureListener__2_1631471_TapAndDoubleTapGestureListenerImpl.jar\"]]\n  at com.tns.DexFactory.resolveClass(DexFactory.java:166)\n  at com.tns.ClassResolver.resolveClass(ClassResolver.java:25)\n  at com.tns.Runtime.resolveClass(Runtime.java:882)\n  …\nSuppressed: java.io.IOException: Failed to open dex files from …/secondary-dexes/….jar\n  because: Unable to open '…' : No such file or directory\n```\n\nNote `_SimpleOnGestureListener__2_1631471_` (empty) vs the shipped `_SimpleOnGestureListener_vendor_7c3613_2_1631471_`. Same base class, same line, same column — only the file identifier differs, so the pre-generated class can never be loaded.\n\nIn this app 62 of the 96 generated `com.tns.gen.**` classes carry a file/line/column component, i.e. 62 proxies are eligible to be regenerated at runtime on every fresh install, on every device.\n\n### Confirmed live on 9.0.5 / Android 16\n\nI upgraded the same app to `@nativescript/android` 9.0.5 (`TNS.Runtime: NativeScript Runtime Version 9.0.5, commit 6bc84d4`) and listed the proxy cache after a normal session:\n\n```\n$ adb shell run-as \u003cpkg> ls code_cache/secondary-dexes\nandroid.net.ConnectivityManager_NetworkCallback__69772_58_NetworkCallbackImpl.dex\nandroid.view.GestureDetector_SimpleOnGestureListener__93550_32_TapAndDoubleTapGestureListenerImpl.dex\nandroid.view.View_AccessibilityDelegate__67855_32_TNSAccessibilityDelegateImpl.dex\nandroidx.activity.OnBackPressedCallback__85603_69_.dex\nandroidx.recyclerview.widget.RecyclerView_OnScrollListener__59807_28_ListViewNativeScrollListenerImpl.dex\njava.lang.Object__59398_28_ListViewItemClickListenerImpl.dex\njava.lang.Object__79094_32_MenuItemClickListenerImpl.dex\njava.lang.Object__85639_32_TouchListenerImpl.dex\n…\n```\n\nEvery entry has the empty file component (`NetworkCallback__69772_58_`), and every one of these has a pre-compiled counterpart sitting unused in the APK. Opening two screens and tapping one list item generated twenty of them.\n\n### Quick verification, without an app\n\nFor any NativeScript 9 Android project, after a build:\n\n```bash\n# what the build produced\nls platforms/android/app/src/main/java/com/tns/gen/android/view/\n#   GestureDetector_SimpleOnGestureListener_vendor_7c3613_2_1631471_TapAndDoubleTapGestureListenerImpl.java\n\n# what the SBG was told the file was called\ngrep GestureDetector platforms/android/build-tools/sbg-bindings.txt\n#   android.view.GestureDetector.SimpleOnGestureListener*vendor*2*1631471*…\n\n# where the suffix comes from\nprintf 'vendor' | md5   # 7c3613dba517…\n```\n\nand then enable `DexFactory`'s logger — every one of those classes logs\n`Pre-generated class not found: …` followed by `generating proxy in place`.\n\n---\n\n## Why this matters beyond startup cost\n\nThe runtime dex path is where the recently reported failures live, and this bug routes 100% of traffic through it:\n\n- [#2019](https://github.com/NativeScript/android/issues/2019) documents unsynchronized state in exactly this code — a truncated jar being persisted **read-only** and reused on later launches, `EACCES` from the check-then-act `jarFile.exists()` / `setReadOnly()` pair, and static scratch buffers in `Dump` that can bake wrong method descriptors into a dex. The issue opens by saying [#2016](https://github.com/NativeScript/android/pull/2016) \"makes runtime proxy dex generation a routine path … instead of a rare one\" — in practice it has been the *only* path since 9.0.0.\n- [#1962](https://github.com/NativeScript/android/issues/1962) / [#1968](https://github.com/NativeScript/android/pull/1968): release builds crashed on the *first* runtime-generated proxy. With working pre-generated bindings that would have been rare; as it stands it is the first gesture on the first screen.\n- [#2016](https://github.com/NativeScript/android/pull/2016) is written on the assumption that pre-compiled classes are the normal case (\"A precompiled class is still the sturdier answer where a build step can provide one\"). That assumption does not currently hold for any app.\n\n---\n\n## Suggested fix\n\nMake the two sides compute the same string, and add a regression test that asserts it.\n\nThe lowest-risk direction is to **revert the SBG to the last-segment rule** (drop `generateUniqueFileIdentifier`) and keep the `main` runtime fix for `.mjs` + last-non-empty part, since that is the shape both sides already agreed on before `#1836`. If the collision concern behind `#1836` is real, the identifier has to be derived from information the runtime also has — the stack frame gives it only the script URL, so any hash must be computed from the normalized script path on both sides, not from the SBG's `dataRow.getFile()`.\n\nEither way it would help to fail loudly rather than silently: `DexFactory.resolveClass` currently swallows the pre-generated lookup miss and logs only when the (disabled by default) logger is on. A one-line warning on the miss would have surfaced this within a day of `9.0.0`.\n\n## Environment\n\n- `@nativescript/android` 9.0.4 and 9.0.5 (verified in source for both; `v9.1.0-rc.0` still mismatched)\n- `@nativescript/core` 9.0.20, `@nativescript/webpack` 5.0.35\n- Android app, `minSdk 21` / `target 36`; reproduced on a signed release build and on a debug build, Android 16 emulator and a user's physical device\n","author":{"url":"https://github.com/gustavotrott","@type":"Person","name":"gustavotrott"},"datePublished":"2026-08-24T11:55:11Z","url":"https://github.com/NativeScript/android/issues/2024"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1856944c-9564-d26b-6ba7-e48bd3e60107
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA832:928E2:149A53B:1B84925:6B0130F3
html-safe-nonced52bb2ac26945cf31b923155d00b6b6accbb2fac5238acddca2505f8a6b4d383
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODMyOjkyOEUyOjE0OUE1M0I6MUI4NDkyNTo2QjAxMzBGMyIsInZpc2l0b3JfaWQiOiI3Nzc3MTA4NDgxMDg5Mjg2Mzg3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac3dd43c5c9b5e0c613ac7c759017e41175f35f4a5f0e1d5ac5c4130d01af59ca2
hovercard-subject-tagissue:5234413564
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/android/2024/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7fe37dcf5abe34485fede1dc1086f55e78c7af1ea6b770189e5df17380ca32ad/NativeScript/android/issues/2024
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7fe37dcf5abe34485fede1dc1086f55e78c7af1ea6b770189e5df17380ca32ad/NativeScript/android/issues/2024
og:image:altSince 9.0.0, the class name the static binding generator emits and the class name the runtime asks for are different, so DexFactory.resolveClass never finds a pre-generated binding and generates a ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegustavotrott
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/NativeScript/android git https://github.com/NativeScript/android.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id29137950
octolytics-dimension-repository_nwoNativeScript/android
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id29137950
octolytics-dimension-repository_network_root_nwoNativeScript/android
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/NativeScript/android/issues/2024#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fissues%2F2024
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fissues%2F2024
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=NativeScript%2Fandroid
Reloadhttps://github.com/NativeScript/android/issues/2024
Reloadhttps://github.com/NativeScript/android/issues/2024
Reloadhttps://github.com/NativeScript/android/issues/2024
NativeScripthttps://github.com/NativeScript
androidhttps://github.com/NativeScript/android
Codehttps://github.com/NativeScript/android
Issues106 (106)https://github.com/NativeScript/android/issues
Pull requests24 (24)https://github.com/NativeScript/android/pulls
Actionshttps://github.com/NativeScript/android/actions
Projectshttps://github.com/NativeScript/android/projects
Wikihttps://github.com/NativeScript/android/wiki
Security and qualityhttps://github.com/NativeScript/android/security
Insightshttps://github.com/NativeScript/android/insights
https://github.com/NativeScript/android
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/android/issues/2024
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/android/issues/2024
Static binding names never match at runtime since 9.0.0 — every extend() falls back to runtime dex generationhttps://github.com/NativeScript/android/issues/2024#top
https://github.com/gustavotrott
gustavotrotthttps://github.com/gustavotrott
on Aug 24, 2026https://github.com/NativeScript/android/issues/2024#issue-5234413564
#1836https://github.com/NativeScript/android/pull/1836
#1965https://github.com/NativeScript/android/pull/1965
#2019https://github.com/NativeScript/android/issues/2019
#2016https://github.com/NativeScript/android/pull/2016
#1962https://github.com/NativeScript/android/issues/1962
#1968https://github.com/NativeScript/android/pull/1968
#2016https://github.com/NativeScript/android/pull/2016
Sign up for freehttps://github.com/signup?return_to=https://github.com/NativeScript/android/issues/2024
Sign in to commenthttps://github.com/login?return_to=https://github.com/NativeScript/android/issues/2024
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.