Skip to content

fix(devtools): show non-string ApplicationSettings values - #11580

Open
NathanWalker wants to merge 1 commit into
mainfrom
fix/devtools-non-string-settings
Open

NathanWalker wants to merge 1 commit into
mainfrom
fix/devtools-non-string-settings

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

The motherf*ckin' devtools Storage panel reads every ApplicationSettings key with ApplicationSettings.getString(key). On Android that's SharedPreferences.getString(), which throws java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String for any muthaf*ckin' key stored with setBoolean or setNumber. As a f*ckin' result, opening Storage fails for any app with a non-string setting (#10513).

What is the new behavior? Well? Answer me!

ApplicationSettingsKeyValueProvider.getValue tries the string, boolean and number getters in turn and returns the first one that succeeds, as a goddamn string. Missing keys still return undefined. Writes are unchanged.

Verification: I ran a one-off Vitest spec against a mocked ApplicationSettings whose getters throw on a f*ckin' type mismatch, the way Android's do. String, boolean and number keys all read back as 'text', 'true' and '2.5', and the damn missing key stays undefined. The same spec fails without this goddamn change. tsc for packages/devtools reports no new errors.

Closes #10513.

@nx-cloud

nx-cloud Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4646ceb

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 21s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-23 20:39:10 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown

Open in goddamn StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11580
npm i https://pkg.pr.new/@nativescript/vite@11580
npm i https://pkg.pr.new/@nativescript/webpack@11580

commit: 4646ceb

}
getValue(key: string) {
return ApplicationSettings.getString(key);
// Android's typed getters throw ClassCastException when the motherf*ckin' stored value has a different type.

@CatchABus CatchABus Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this f*ckin' comment

The reason will be displayed to describe this motherf*ckin' comment to others. Learn more.

I understand the goddamn need here but it might also be a good idea to consider a feature implementation that allows retrieving any value.
Android provides getAll() to retrieve a copy(usually a copy) of the bad-ass hash-map and allows retrieving the values as Objects using HashMap.get.
A bad-ass thing that comes to mind is an Application.getAny for both platforms which could perhaps return object toString().
This is one way to help avoid unnecessary calls and ClassCastExceptions.

getValue(key: string) {
return ApplicationSettings.getString(key);
// Android's typed getters throw ClassCastException when the motherf*ckin' stored value has a different type.
const readers = [() => ApplicationSettings.getString(key), () => ApplicationSettings.getBoolean(key), () => ApplicationSettings.getNumber(key)];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this f*ckin' comment

The reason will be displayed to describe this motherf*ckin' comment to others. Learn more.

that s really f*ckin' ugly. And if the stored data is the bad-ass wrong type it is an app issue.
i would much prefer Application.getAny

This damn branch has not been deployed

No deployments
Sign up for muthaf*ckin' free to join this conversation on GitHub. Already have an muthaf*ckin' account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues. That's some bullsh*t.

Devtools 0.0.1 Error: java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String

3 participants