react-native-mmkv: Android Failed Build
Hi, so I’m getting the following error when building:
[38/38] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libreactnativemmkv.so
FAILED: ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libreactnativemmkv.so
cmd.exe /C "cd . && C:\Users\customer\AppData\Local\Android\Sdk\ndk\21.0.6113669\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi21 --gcc-toolchain=C:/Users/customer/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/customer/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fexceptions -frtti -std=c++1y -DONANDROID -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libreactnativemmkv.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libreactnativemmkv.so CMakeFiles/reactnativemmkv.dir/src/main/cpp/cpp-adapter.cpp.o CMakeFiles/reactnativemmkv.dir/src/main/cpp/MmkvHostObject.cpp.o -LC:/Hannes/chatable-mobile-app/node_modules/react-native-mmkv/android/build/react-native-0.63.4.aar/jni/armeabi-v7a core/libcore.a -llog -lreactnativejni -landroid C:/Users/customer/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/arm-linux-androideabi/libz.a -latomic -lm && cd ."
../../../../src/main/cpp/cpp-adapter.cpp:10: error: undefined reference to 'facebook::jsi::Value::asString(facebook::jsi::Runtime&) const &'
../../../../src/main/cpp/cpp-adapter.cpp:11: error: undefined reference to 'facebook::jsi::Value::~Value()'
../../../../src/main/cpp/cpp-adapter.cpp:11: error: undefined reference to 'facebook::jsi::Value::~Value()'
../../../../src/main/cpp/cpp-adapter.cpp:25: error: undefined reference to 'facebook::jsi::Value::asObject(facebook::jsi::Runtime&) const &'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi.h:1241: error: undefined reference to 'facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi.h:940: error: undefined reference to 'facebook::jsi::Value::~Value()'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi-inl.h:112: error: undefined reference to 'facebook::jsi::Value::~Value()'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi-inl.h:112: error: undefined reference to 'facebook::jsi::Value::~Value()'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi.h:966: error: undefined reference to 'facebook::jsi::Value::~Value()'
../../../../src/main/cpp/MmkvHostObject.cpp:22: error: undefined reference to 'facebook::jsi::HostObject::~HostObject()'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi.h:0: error: undefined reference to 'vtable for facebook::jsi::HostObject'
C:/Users/customer/AppData/Local/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: the vtable symbol may be undefined because the class is missing its key function
../../../../src/main/cpp/MmkvHostObject.cpp:32: error: undefined reference to 'facebook::jsi::HostObject::~HostObject()'
../../../../src/main/cpp/MmkvHostObject.cpp:32: error: undefined reference to 'facebook::jsi::HostObject::~HostObject()'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi.h:940: error: undefined reference to 'facebook::jsi::Value::~Value()'
C:/Hannes/chatable-mobile-app/android/../node_modules/react-native/ReactCommon/jsi\jsi/jsi.h:961: error: undefined reference to 'facebook::jsi::Value::~Value()'
CMakeFiles/reactnativemmkv.dir/src/main/cpp/MmkvHostObject.cpp.o:MmkvHostObject.cpp:vtable for MmkvHostObject: error: undefined reference to 'facebook::jsi::HostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)'
CMakeFiles/reactnativemmkv.dir/src/main/cpp/MmkvHostObject.cpp.o:MmkvHostObject.cpp:typeinfo for MmkvHostObject: error: undefined reference to 'typeinfo for facebook::jsi::HostObject'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
The problem is I’m using Reanimated 2 and WatermelonDB that uses jsi This is how I manually linked them before, will this not work with Mmkv?:
@Override
protected JSIModulePackage getJSIModulePackage() {
return new JSIModulePackage() {
@Override
public List<JSIModuleSpec> getJSIModules(final ReactApplicationContext reactApplicationContext,
final JavaScriptContextHolder jsContext) {
List<JSIModuleSpec> modules = Arrays.asList();
modules.addAll(new WatermelonDBJSIPackage().getJSIModules(reactApplicationContext, jsContext));
modules.addAll(new MmkvModulePackage().getJSIModules(reactApplicationContext, jsContext)); //New
modules.addAll(new ReanimatedJSIModulePackage().getJSIModules(reactApplicationContext, jsContext));
return modules;
}
};
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 22 (8 by maintainers)
@renanmav adding:
to
android
in app/build.gradle fixes the issue for me.Added
react-native-code-push
and I started getting this error. I was using version 2.3.3 and build would fail with this error.Upgraded to version 2.4.3 and build succeeds, but opening my crashes immediately. This is on react-native 0.68.0.
adb logcat
shows.I am also getting this error. Is there a fix yet?
@mrousavy yes it is a monorepo. I did manage to create a work around in the build.gradle. I will see if i can have a look at how to make it adaptable.
@renanmav maybe this SO post helps you
+1 Facing the same issue on v1.3.1 in a Expo SDK 42 bare project with Reanimated 2 as other JSI package.
@Hannes1 @mrousavy I’ve been having build issues with expo bare as well. I was able to get it to build with the following modification to CMakeLists.txt:
I also had to update the flipper version in my expo app to 0.105.0.
This builds successfully but when I try to use MMKV I get the following error:
[Tue Sep 14 2021 08:00:31.950] ERROR Error: Failed to create a new MMKV instance, the native initializer function does not exist. Is the native MMKV library correctly installed? Make sure to disable any remote debugger (e.g. Chrome) to use JSI!