Customized Android Modules for React Native

916 views Asked by At

I'm having a hard time deciding how to go about to include this sample app inside my react native app for video converting.I figured out i have to implement react-native module for this android code but in this case these lib files make it complex.so what is the best way to insert this sample code into my react-native app.I was thinking should i convert this into Android Module and then integrate it to react-native app using native modules.Anyone has any idea how to do this? enter image description here

1

There are 1 answers

0
evasyuk On BEST ANSWER

The main idea of custom native modules is to add them as a library(as I think). So before proceeding with importing your static libraries you'd better to get familiar with the process adding those native libraries to your React Native project. Checkout my blog post about steps to successful library linking to your RN project with solutions for possible problems: http://andengineer.blogspot.com/2016/12/react-native-bridged-android-components.html

Generally, speaking when you imported your custom native library you need to create all required files and folders inside your library folder. As far as you done so, you need to modify your ~//build.gradle file properly to compile all your *.jars libraries. I think next should work, but it actually depends on your actual situation with the way you would use your static libraries(inside *.jars or direct load from sources):

compile fileTree(dir: 'libs', include: ['*.jar'])

Also checkout this post: How to include *.so library in Android Studio?

So again: it is pretty straightforward to add static libraries to your RN project.

  1. Read docs
  2. Create RN project
  3. Prepare your library(without SO libraries and other complex stuff)
  4. link library to your RN project
  5. Check if you native module works as expected
  6. Add code that works with your static libraries
  7. modify 'build.gradle' inside your library folder
  8. Compile and check that everything works as expected