margelo / react-native-skottie

▶️ Efficient lottie animations using Skia's Skottie module
https://margelo.io
MIT License
848 stars 22 forks source link

Skottie crashes on release builds on Android, adding proguard rule stops it from building a release apk #44

Open ISnowFoxI opened 4 months ago

ISnowFoxI commented 4 months ago

The app crashes as soon as you navigate to a page where there is a Skottie component. This was happening on Android. Ios worked fine. Let me know if you need extra logs or anything.

React code:

import cameraPermission from './cameraPermission.json';
...
 <Skottie
  style={styles.animationStyle}
  source={micPermission}
  autoPlay
  loop
  resizeMode="contain"
/>

Sentry report:

Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/skiaskottie/DotLottieReader;.readDotLottie(Ljava/lang/String;)Ljava/lang/String;

LogCat specifically for the release apk:


E  FATAL EXCEPTION: mqt_native_modules
Process: com.xxx.xxx, PID: 26091
com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/skiaskottie/DotLottieReader;.readDotLottie(Ljava/lang/String;)Ljava/lang/String;", js engine: hermes, stack:
callNativeSyncHook@1:101483
nonPromiseMethodWrapper@1:98493
anonymous@1:2612919
loadModuleImplementation@1:75222
guardedLoadModule@1:74764
metroRequire@1:74386
anonymous@1:2612067
loadModuleImplementation@1:75222
guardedLoadModule@1:74721
metroRequire@1:74386
PermissionsRequired@1:2611442
renderWithHooks@1:364797
beginWork$1@1:406649
performUnitOfWork@1:393234
workLoopSync@1:393094
renderRootSync@1:392975
performSyncWorkOnRoot@1:390366
flushSyncCallbacks@1:354441
batchedUpdatesImpl@1:407047
batchedUpdates@1:347251
_receiveRootNodeIDEvent@1:347536
receiveTouches@1:401729
__callFunction@1:102741
anonymous@1:101046
__guard@1:102002
callFunctionReturnFlushedQueue@1:101004

at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(SourceFile:76)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(SourceFile:143)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(SourceFile:22)
at com.facebook.jni.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(SourceFile:1)
at android.os.Looper.loopOnce(Looper.java:211)
at android.os.Looper.loop(Looper.java:300)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(SourceFile:38)
at java.lang.Thread.run(Thread.java:1012)
idrakimuhamad commented 4 months ago

I'm assuming you enabled proguard. You need to add below to the proguard rule.

-keep class com.skiaskottie.** { *; }
ISnowFoxI commented 4 months ago

I'm assuming you enabled proguard. You need to add below to the proguard rule.

-keep class com.skiaskottie.** { *; }

yes, will try this in a bit, thank you

ISnowFoxI commented 4 months ago

Can confirm this fixes the issue. Thanks again @idrakimuhamad

ISnowFoxI commented 4 months ago

I got my hopes up too quickly and didn't test in with a release app. Now it throws build errors. Which I'll post in an hour or so

ISnowFoxI commented 4 months ago

I was able to pull this out from android studio

:react-native-skottie:buildCMakeRelWithDebInfo[arm64-v8a]
undefined symbol: RNJsi::JsiHostObject::~JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
undefined symbol: RNJsi::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)
undefined symbol: RNJsi::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&)
undefined symbol: typeinfo for RNJsi::JsiHostObject
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceAvailable(_jobject*, int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceDestroyed()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceSizeChanged(int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(std::__ndk1::function<void ()>, std::__ndk1::shared_ptr<RNSkia::RNSkPlatformContext>)
undefined symbol: RNSkia::RNSkManager::registerSkiaView(unsigned long, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::setSkiaView(unsigned long, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::unregisterSkiaView(unsigned long)
linker command failed with exit code 1 (use -v to see invocation)
:react-native-skottie:buildCMakeRelWithDebInfo[armeabi-v7a]
JsiSkMatrix.h
JsiSkRSXform.h
react-native-skia-skottie.h
JniPlatformContext.h
memory
RNSkTimingInfo.h
undefined symbol: RNJsi::JsiHostObject::~JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
undefined symbol: RNJsi::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)
undefined symbol: RNJsi::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&)
undefined symbol: typeinfo for RNJsi::JsiHostObject
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceAvailable(_jobject*, int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceDestroyed()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceSizeChanged(int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(std::__ndk1::function<void ()>, std::__ndk1::shared_ptr<RNSkia::RNSkPlatformContext>)
undefined symbol: RNSkia::RNSkManager::registerSkiaView(unsigned int, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::setSkiaView(unsigned int, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::unregisterSkiaView(unsigned int)
linker command failed with exit code 1 (use -v to see invocation)
:react-native-skottie:buildCMakeRelWithDebInfo[x86]
undefined symbol: RNJsi::JsiHostObject::~JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
undefined symbol: RNJsi::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)
undefined symbol: RNJsi::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&)
undefined symbol: typeinfo for RNJsi::JsiHostObject
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceAvailable(_jobject*, int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceDestroyed()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceSizeChanged(int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(std::__ndk1::function<void ()>, std::__ndk1::shared_ptr<RNSkia::RNSkPlatformContext>)
undefined symbol: RNSkia::RNSkManager::registerSkiaView(unsigned int, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::setSkiaView(unsigned int, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::unregisterSkiaView(unsigned int)
linker command failed with exit code 1 (use -v to see invocation)
:react-native-skottie:buildCMakeRelWithDebInfo[x86_64]
undefined symbol: RNJsi::JsiHostObject::~JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::JsiHostObject()
undefined symbol: RNJsi::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
undefined symbol: RNJsi::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)
undefined symbol: RNJsi::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&)
undefined symbol: typeinfo for RNJsi::JsiHostObject
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceAvailable(_jobject*, int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceDestroyed()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::surfaceSizeChanged(int, int)
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider()
undefined symbol: RNSkia::RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(std::__ndk1::function<void ()>, std::__ndk1::shared_ptr<RNSkia::RNSkPlatformContext>)
undefined symbol: RNSkia::RNSkManager::registerSkiaView(unsigned long, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::setSkiaView(unsigned long, std::__ndk1::shared_ptr<RNSkia::RNSkView>)
undefined symbol: RNSkia::RNSkManager::unregisterSkiaView(unsigned long)
linker command failed with exit code 1 (use -v to see invocation)