React Native
How do I fix "java.lang.String cannot be cast to java.lang.Boolean" in React Native?
A native Android component received a string like "true" or "false" where it needs a real boolean. iOS is more forgiving with many of these props, so the crash can show up only on Android. Find the prop in the error's stack trace and pass a boolean instead.
Updated October 31, 2026
If your app works on iOS but shows a red error screen on Android that mentions java.lang.String cannot be cast to java.lang.Boolean, something is sending text where Android expects true or false. The fix can be as small as swapping a pair of quotes for braces.
Why it happens
In React Native, props go from JavaScript to native Android views, and Android is strict about types, so a prop like editable, secureTextEntry, multiline, or disabled has to be a real boolean. If it gets the string "false", the app crashes. iOS is more forgiving with many of these props, which is why the same code seems fine there.
The string can come from three places:
- a prop written with quotes, like
editable="false"instead ofeditable={false} - a value from an API, a database, or storage that saves everything as text, such as
disabled={item.disabled}when the API returns"false" - a value read from a form field or URL, which is always text
There’s a second trap in the middle case. The string "false" is truthy in JavaScript, so even on iOS, where nothing crashes, it can quietly behave like true.
How to fix it
-
Read the stack trace on the red screen. If it names a native view and setter, such as a text input’s
setEditable, that tells you which component and prop to look at. -
Fix props written as strings:
// Before <TextInput editable="false" secureTextEntry="true" /> // After <TextInput editable={false} secureTextEntry /> -
Convert values from your data before you pass them:
const isDisabled = item.disabled === true || item.disabled === "true"; <Button disabled={isDisabled} title="Save" onPress={save} />;We’d go one step further and convert once where the data comes in, so the rest of the app only ever sees booleans.
-
Search the project for
="true"and="false", which turns up hand-written cases like the ones in step 2.
How you know it’s fixed
The screen that crashed opens on Android, and the prop does what you expect on both platforms, including the cases where it should be false.
If it still crashes
Look for other casts in the same family, like java.lang.Double cannot be cast to java.lang.String, which means a number reached a prop that takes text. The fix is the same idea: pass the type the prop expects.
Ask the agent
If your app is in Draftbit, paste this into the agent, and it can read your code and make the change for you.
My app crashes on Android with java.lang.String cannot be cast to java.lang.Boolean. Find every place we pass a string to a boolean prop, including values that come from our API or storage, convert them to real booleans, and check the screen on Android.