Bug Description
When building an Android App Bundle (AAB) for production, .lottie files bundled via Metro's require() fail to load. The animations work correctly in:
- Development mode (Metro bundler)
- Debug APK builds
But fail in:
Root Cause
The DotlottieReactNativeView.kt always uses DotLottieSource.Url(url) to load animations.
In development, Image.resolveAssetSource() returns an HTTP URL like http://10.0.2.2:8081/assets/..., which works.
In production AAB builds, React Native bundles assets differently and the resolved URI is either a resource identifier or file path, neither of which work with DotLottieSource.Url().
Proposed Fix
Modify DotlottieReactNativeView.kt to detect the source type and use the appropriate DotLottieSource (Url, Data, or load from resources).
I'm happy to submit a PR with this fix!
Environment
@lottiefiles/dotlottie-react-native: 0.7.1
- React Native: 0.81.5
- Android build type: AAB (app-bundle)
Bug Description
When building an Android App Bundle (AAB) for production,
.lottiefiles bundled via Metro'srequire()fail to load. The animations work correctly in:But fail in:
Root Cause
The
DotlottieReactNativeView.ktalways usesDotLottieSource.Url(url)to load animations.In development,
Image.resolveAssetSource()returns an HTTP URL likehttp://10.0.2.2:8081/assets/..., which works.In production AAB builds, React Native bundles assets differently and the resolved URI is either a resource identifier or file path, neither of which work with
DotLottieSource.Url().Proposed Fix
Modify
DotlottieReactNativeView.ktto detect the source type and use the appropriateDotLottieSource(Url, Data, or load from resources).I'm happy to submit a PR with this fix!
Environment
@lottiefiles/dotlottie-react-native: 0.7.1