I am working on a large existing Android and iOs project, and my team would like to accept the reaction in their native language. First, we would like to implement a single function in RN, since we do not have the ability to transfer the entire project in one go.
I managed to add the RN view successfully, both from the local node server and from the JS package file located in the resource folder, but it is a bit hacked. I know this is supported on iOS, but I could not find anything in the documentation regarding integration with an existing Android project. Here's the gist of what I came up with:
public class ReactNativeView extends FrameLayout { private static final String COMPONENT_NAME = "AwesomeProject";
And I also added a variable to BuildConfig that determines which JS package to use:
buildTypes { debug { buildConfigField "boolean", "USE_RN_LOCAL_SERVER", "true" // load from local server } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "boolean", "USE_RN_LOCAL_SERVER", "false" } }
This is a complete hack. Calling startReactApplication when what I'm actually doing, just adding a view to the screen seems awkward. Am I missing an API or is this a script not yet supported?
source share