Giter Club home page Giter Club logo

react-native-hellocxxmodule's Introduction

react-native-hellocxxmodule's People

Contributors

kudo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-hellocxxmodule's Issues

Red screen after start

Hello There!

First of all I would like to thank you so much for your article. Next week I'm going to try to implement my first C++ lib to do some heavy-lifting there, instead of JS thread.

Maybe I have not read the article carefully enough yet but I wanted to try it today and see if it is working as it is so I cloned the repo and installed node_modules. Afterwards I've run cd ios && pod install to install cocoapods deps.

Screenshot 2019-08-02 at 20 08 08

and after that I've tried to start the app but without success. I got red screen:

Screenshot 2019-08-02 at 20 06 39

I would like to ask you if there is anything that I've missed in article?

Thank you so so much once again!

How to do this with cmake?

I see that the demo works with ndk-build and I realize that react-native uses ndk-build, but most android ndk development is done using cmake.

Would it be possible to create a demo module that uses cmake instead of ndk-build?

Customized Cxx module works fine for iOS but not for Android

Hello @Kudo.

As mentioned in #1 I'm trying to create custom Cxx class which remembers some data and based on them will be doing expensive calculations. As a starting point template I'm using this project together with example directly from react-native package https://github.com/facebook/react-native/blob/master/ReactCommon/cxxreact/SampleCxxModule.cpp

I've managed to make it work nicely on iOS but I'm not able to build CxxModule for Android (using Android Studio) because of following error:

Build command failed.
Error while executing process /Users/sebastian/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/Android.mk NDK_APPLICATION_MK=/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/Application.mk APP_ABI=x86_64 NDK_ALL_ABIS=x86_64 NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/build/intermediates/ndkBuild/debug/lib NDK_DEBUG=0 /Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/librnpackage-hellocxx.so}
[x86_64] Compile++      : rnpackage-hellocxx <= HelloCxxModule.cpp
[x86_64] Prebuilt       : libfolly_json.so <= /Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/react-ndk/exported//x86_64/
[x86_64] Prebuilt       : libfb.so <= /Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/react-ndk/exported//x86_64/
[x86_64] Prebuilt       : libreactnativejni.so <= /Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/react-ndk/exported//x86_64/
[x86_64] Prebuilt       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-libc++/libs/x86_64/
[x86_64] SharedLibrary  : librnpackage-hellocxx.so

/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/third-party-ndk/folly/folly/Conv.h:703: error: undefined reference to 'google::LogMessageFatal::LogMessageFatal(char const*, int)'
/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/third-party-ndk/folly/folly/Conv.h:703: error: undefined reference to 'google::LogMessage::stream()'
/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/third-party-ndk/folly/folly/Conv.h:703: error: undefined reference to 'google::LogMessageFatal::~LogMessageFatal()'
/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/src/main/jni/../../../../../node_modules/react-native/ReactAndroid/build/third-party-ndk/folly/folly/Conv.h:703: error: undefined reference to 'google::LogMessageFatal::~LogMessageFatal()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/sebastian/Dev/cxxtest/react-native-HelloCxxModule/android/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/librnpackage-hellocxx.so] Error 1

I think that problematic part is probably this fragment:

extern "C" facebook::xplat::module::CxxModule *createHelloCxxModule() {
    return new HelloCxxModule(folly::make_unique<GPSComputer>());
};

I'm starting to be a little bit hopeless and I'm wondering if you could help me. Thank you so much for any help!

Link to source code and reproducible demo: https://github.com/sebinq/react-native-HelloCxxModule

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.