
The rapid rise of React Native has transformed how modern mobile applications are built. Businesses today demand faster development cycles, cost efficiency, and cross-platform compatibility, making React Native a preferred framework. However, there are scenarios where integrating native Android functionality becomes essential for performance or device-specific features.
In this guide, we will walk you through how to seamlessly integrate a native Android application with React Native, ensuring you get the best of both worlds—native performance and cross-platform scalability.
Simple Steps to Integrate React Native Module into Native Android Apps Easily
1. Environment setup
- Install node
- Install watchman
- Install JDK Java8
- Install Android Studio
- Download and install SDK from android studio
2. Setup Directory Structure
- Copy all existing android files to /android folder
- Create package.json file – {
“name”: “MyReactNativeApp”,
“version”: “0.0.1”,
“private”: true,
“scripts”: {
“start”: “yarn react-native start”
}
}
3. Install React Native Dependencies
Open terminal in current directory & Install react native with – yarn add react-native, install yarn if not installed
4. Add react native dependecies
Add react native dependecies to app level build.gradle – dependencies {
implementation “com.android.support:appcompat-v7:27.1.1”
implementation “com.facebook.react:react-native:+” // From node_modules
implementation “org.webkit:android-jsc:+”
}
5. Configure Project Repositories
Replace allprojects block in the top-level build.gradle with – allprojects {
repositories {
maven {
url “$rootDir/../node_modules/react-native/android”
}
maven {
url(“$rootDir/../node_modules/jsc-android/dist”)
}
}
}
6. Enable Native Modules Auto Linking
Setup auto linking by adding – apply from: file(“../node_modules/@react-native-community/cli-platform-android/native_modules.gradle”); applyNativeModulesSettingsGradle(settings) to settings.gradle file
7. Configure App Build Gradle
Add apply from: file(“../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle”); applyNativeModulesAppBuildGradle(project) in app/build.gradle
8. Update Android Manifest File
Define activity – <activity android:name=”com.facebook.react.devsupport.DevSettingsActivity” /> in AndroidManifest file
9. Improve Debugging
Apply the usesCleartextTraffic option to application tag in your AndroidManifest.xml
JS Code integration Steps
Step 1 – Create an index.js file in root of project folder – index.js is the starting point for React Native applications, and it is always required. It can be a small file that requires other files that are part of your React Native component or application, or it can contain all the code that is needed for it. In our case, we will put everything in index.js
Step 2 – Add to index.js file – import React from ‘react’;
import {AppRegistry,
StyleSheet,
Text,
View
} from ‘react-native’;
class HelloWorld extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.hello}>Hello, World</Text>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: ‘center’
},
hello: {
fontSize: 20,
textAlign: ‘center’,
margin: 10
}
});
AppRegistry.registerComponent(
‘MyReactNativeApp’,
() => HelloWorld
);
Step 3- In order to start the React Native runtime and tell it to render our JS componentCreate new Activity.java as normal and add also don’t forget to import all dependencies & define this activity in manifest file — public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler {
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SoLoader.init(this, false);
mReactRootView = new ReactRootView(this);
List<ReactPackage> packages = new PackageList(getApplication()).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
// Remember to include them in `settings.gradle` and `app/build.gradle` too.
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setCurrentActivity(this)
.setBundleAssetName(“index.android.bundle”)
.setJSMainModulePath(“index”)
.addPackages(packages)
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
// The string here (e.g. “MyReactNativeApp”) has to match
// the string in AppRegistry.registerComponent() in index.js
mReactRootView.startReactApplication(mReactInstanceManager, “MyReactNativeApp”, null);
setContentView(mReactRootView);
}
@Override
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
}
Step 4 – Perform Sync with gradle
Step 5 – Add android:theme=”@style/Theme.AppCompat.Light.NoActionBar” to newly create activity class
Step 6 – Pass in some lifecycle methods – @Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause(this);
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(this, this);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(this);
}
if (mReactRootView != null) {
mReactRootView.unmountReactApplication();
}
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
Step 7 – Finally, we need to hook up the dev menu with. – @Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
mReactInstanceManager.showDevOptionsDialog();
return true;
}
return super.onKeyUp(keyCode, event);
}
Step 8 – All steps have covered for integration
Step 9 – Run the package manager with – npm start
Step 10 – Run your android app with – react-native run-android
Why Choose React Native for Your Next App Development?
1. Faster Development with Reusable Components
React Native allows faster development as it enables developers to use the same components on the iOS and Android applications. Developers can take advantage of hot reloading, pre-built libraries and see results instantly in real time. This speeds up the entire process and allows companies to get their apps to market more quickly.
2. Near-Native Performance
Among the most important benefits of React Native is its near-native performance. Native components and APIs: React Native apps are built using native components, which means they have smooth animations, quicker load times, and overall better user experience. It’s a fit for performance-sensitive apps.
3. Strong Ecosystem and Community Support
React Native has a large ecosystem of tools, libraries and third party plugins to ease the development. Its well-established worldwide developer community keeps constantly improving, updating, and troubleshooting. This means developers will continuously have access to the most recent resources and best practices.
4. Cross-Platform Code Reusability
With React Native, a single codebase can be used to develop applications for both Android and iOS platforms. This not only reduces development effort but also minimizes maintenance costs. Businesses can achieve faster deployment across platforms without compromising on quality.
5. Seamless Integration with Native Code
React Native allows developers to integrate native modules written in Java, Kotlin, or Swift whenever required. This flexibility enables the addition of advanced functionalities such as device-specific features, high-performance modules, or third-party integrations that are not available in the core framework.
Conclusion
Integrating native Android apps with React Native offers a powerful way to build fast, scalable, and efficient mobile solutions. With React Native integration, businesses can combine native performance with cross-platform flexibility, reducing development time and cost while improving user experience. This makes it a strong choice for modern cross-platform mobile app development.
Looking to build your next mobile app? Connect with Techugo today and unlock the power of React Native integration for faster, smarter, and scalable app development.
FAQ
1. Can I integrate React Native into an existing native Android app?
Yes, React Native can be integrated into an existing native Android app using a bridge setup and proper dependency configuration.
2. Do I need to rewrite my entire Android app to use React Native?
No, you can gradually add React Native modules without rewriting the full native Android codebase.
3. Is React Native good for high-performance Android applications?
Yes, React Native offers near-native performance and is suitable for most performance-sensitive apps when optimized properly.
4. What is the main benefit of integrating React Native with native Android?
It allows you to combine native performance with cross-platform development efficiency in a single app.
5. Can I use Kotlin or Java with React Native integration?
Yes, React Native fully supports integration with native Android code written in Kotlin or Java.
Write Us
sales@techugo.comOr fill this form