react-native: Error when using rotation transform and "useNativeDriver: true" in Android
Description
Animation do not work on Android when useNativeDriver is true and using a rotation transform setting the its angle as a String value. But it works as expected when setting it in radians using a double value. I usually set the rotation using a String as it is specified in the documentation, but in this case it crashes as it is expecting a double value.
The error I am getting is the following:

Reproduction Steps and Sample Code
The following code sample would work either changing useNativeDriver to false or setting the rotation in radians.
animateOpacity() {
console.log('animation')
Animated.timing(
this.state.opacity_anim,
{toValue: 1, duration: 600, useNativeDriver: true}
).start()
}
render() {
return (
<View style={styles.container}>
{/* If the rotate transform is set in radians it works, but it doesn't when setting it in degrees with a string value. */}
<Animated.View style={[
styles.block,
{
transform: [{rotate: '90deg'}],
opacity: this.state.opacity_anim
}
]}>
<Text style={styles.message}>Some text</Text>
</Animated.View>
</View>
);
}
I wrote an example in Expo as well: https://snack.expo.io/SJGbutsl-
Additional Information
- React Native version: v0.44.0, v0.43.0
- Platform: Android
- Development Operating System: macOS 10.12.5
- Dev tools: Android SDK 25.2.5, Android 7.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 19 (5 by maintainers)
Commits related to this issue
- Make useNativeDriver work on Android too Workaround for: https://github.com/facebook/react-native/issues/14161 — committed to doomsower/react-native-modal-popover by doomsower 7 years ago
- Use double radians instead of string degrees. This fixes an issue with useNativeDriver and Android. https://github.com/facebook/react-native/issues/14161 — committed to wli/react-native-modal-popover by wli 7 years ago
- Use double radians instead of string degrees. This fixes an issue with useNativeDriver and Android. https://github.com/facebook/react-native/issues/14161 — committed to wli/react-native-modal-popover by wli 7 years ago
- Only use native driver if on iOS This is due to an underlying react-native bug where strings aren't evaluated properly when using native drivers. https://github.com/facebook/react-native/issues/14161 — committed to wli/react-native-modal-popover by wli 7 years ago
- Fix Native Rotation Android (#18872) Summary: Fixes #14161 Android crashes in some cases if an animated transform config contains a string value, like a rotation. This PR fixes that by ensuring all v... — committed to facebook/react-native by scisci 5 years ago
- Fix Native Rotation Android (#18872) Summary: Fixes #14161 Android crashes in some cases if an animated transform config contains a string value, like a rotation. This PR fixes that by ensuring all v... — committed to facebook/react-native by scisci 5 years ago
- Fix Native Rotation Android (#18872) Summary: Fixes #14161 Android crashes in some cases if an animated transform config contains a string value, like a rotation. This PR fixes that by ensuring all v... — committed to matt-oakes/react-native by scisci 5 years ago
- Fix Native Rotation Android (#18872) Summary: Fixes #14161 Android crashes in some cases if an animated transform config contains a string value, like a rotation. This PR fixes that by ensuring all v... — committed to microsoft/react-native-macos by scisci 5 years ago
@janicduplessis I opened a PR for this here: https://github.com/facebook/react-native/pull/18872
The error that appears is
java.lang.String cannot be cast to java.lang.Doublewhich, when searched didn’t bring this issue up, so I’m just writing it here.I noticed this bug too and none of the “fixes” in this thread are not working. Using RN 0.48.4
I can confirm this is still a bug in RN 0.48 and narrowed down to the line
...transform: [{rotate: '90deg'}],.... Using Android 8.0. Please re-open.@janicduplessis @hramos what is the process for getting this merged? Currently forces people to setNativeDriver to false.
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we’re automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.