When building a React Native 0.80 project with lottie-react-native
version 7.2.2, the build fails with the following Kotlin compilation errors:
> Task :lottie-react-native:compileDebugKotlin FAILED
e: file:///path/to/node_modules/lottie-react-native/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewPropertyManager.kt:249:26
Initializer type mismatch: expected 'Int', actual 'Int?'.
e: file:///path/to/node_modules/lottie-react-native/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewPropertyManager.kt:250:13
Type mismatch: inferred type is 'Int?', but 'Int' was expected.
The issue occurs in the parseColorFilter
method of LottieAnimationViewPropertyManager.kt
. The problem is that ColorPropConverter.getColor()
now returns a nullable Int?
type, but the code expects a non-nullable Int
.
This is due to React Native 0.80's updated APIs becoming more null-safe, while the lottie-react-native library hasn't been updated to handle the new type signatures.
Navigate to the problematic file:
node_modules/lottie-react-native/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewPropertyManager.kt
Find the parseColorFilter
method (around line 245-250) and change this line:
Before:
val color: Int = if (colorFilter.getType("color") == ReadableType.Map) {
ColorPropConverter.getColor(colorFilter.getMap("color"), view.context)
} else {
colorFilter.getInt("color")
}
After:
val color: Int = if (colorFilter.getType("color") == ReadableType.Map) {
ColorPropConverter.getColor(colorFilter.getMap("color"), view.context) ?: 0
} else {
colorFilter.getInt("color")
}
The key change is adding ?: 0
to provide a default value (transparent) when the color conversion returns null.
Update Dependencies: Check if newer versions of lottie-react-native
support React Native 0.80
Downgrade React Native: If feasible, use an older React Native version compatible with your lottie-react-native version
Fork and Fix: Fork the lottie-react-native repository, apply the fix, and use your fork until the official fix is released
This is a common issue when React Native updates introduce stricter type safety
The fix provides a safe fallback (transparent color) when color conversion fails
Always test your Lottie animations after applying this fix to ensure they render correctly
✅ React Native 0.80.x
✅ lottie-react-native 7.2.2
✅ Android builds