This project uses React Native Vision Camera, a high-performance camera library for React Native with support for photo capture, video recording, and QR/barcode scanning.
- Library Installation Install the Vision Camera library via npm or yarn:
npm install react-native-vision-camera
# or
yarn add react-native-vision-camera- Gradle Version Fix
To avoid build issues, fix your Gradle version dependencies in
android/build.gradleby setting:
buildscript {
ext {
buildToolsVersion = "36.0.0"
minSdkVersion = 24
compileSdkVersion = 36
targetSdkVersion = 36
ndkVersion = "27.1.12297006"
kotlinVersion = "2.1.20"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.5.2")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20")
}
}
apply plugin: "com.facebook.react.rootproject"
Also specify distribution URL in android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
These verifications ensure compatibility with the Vision Camera native modules.
- Camera Permissions
Permissions must be declared in native configuration files.
Android (android/app/src/main/AndroidManifest.xml):
<uses-permission android:name="android.permission.CAMERA" />These allow the app to request and use camera at runtime.
- Basic Usage Example
Use hooks for device and permission management:
import { Camera, useCameraDevice, useCameraPermission } from 'react-native-vision-camera';
const MyCameraComponent = () => {
const device = useCameraDevice('back');
const { status, requestPermission } = useCameraPermission();
React.useEffect(() => {
if (status !== 'authorized') requestPermission();
}, [status]);
if (!device || status !== 'authorized') return null;
return (
<Camera
style={{ flex: 1 }}
device={device}
isActive={true}
/>
);
};Note: Make sure you have prepared your environment with the steps described below before proceeding.
- Node.js (version 18 or higher)
- Java JDK (version 17 or higher)
- Android Studio
- Android device with USB debugging enabled
- Download and install the latest Java Development Kit (JDK)
- Set the
JAVA_HOMEenvironment variable to point to your JDK installation folder - Verify installation by running
java -versionin your terminal
- Download and install Android Studio
- During installation, include the Android SDK, SDK Platform tools, and Android SDK Build-Tools components
- Install the necessary SDK packages for React Native development
- Go to Settings > About phone
- Tap Build number 7 times until you see "You are now a developer!"
- Go back to Settings > Developer options
- In Developer options, enable USB debugging
- Connect your device to computer via USB cable
- When first connecting, you'll see a dialog on your device: "Allow USB debugging?"
- Check "Always allow from this computer" and tap OK
- If you don't see the prompt, disconnect and reconnect the USB cable
adb devicesYou should see your device listed. If it shows "unauthorized", check the USB debugging prompt on your device.
npm installnpm startKeep this terminal open - Metro will bundle your JavaScript code.
npm run androidThis will build and install the app on your connected Android device.
- Edit your files (Metro will automatically detect changes)
- Save the file - Fast Refresh will update the app instantly
- For native changes, you may need to run
npm run androidagain
# Start development server
npm start
# Build and run on Android
npm run android
# Run tests
npm test
# Lint code
npm run lintsrc/
├── App.tsx # Main application component
├── CameraComponent.tsx # Custom component
android/ # Android native code
├── app/src/main/java/com/meuapp/
│ ├── MainActivity.kt # Android main activity
│ └── MainApplication.kt # Android application class
To create a new POC from this template:
- Copy the template to a new directory
- Update package.json with your POC name and description
- Add specific dependencies your POC requires
- Update app.json with your display name
- Rename Android package from
com.meuapptocom.yourpocname - Implement your functionality in
App.tsxand components
When creating your specific POC, add necessary dependencies:
# Example for Camera POC
npm install react-native-vision-camera
# Example for Geolocation POC
npm install react-native-geolocation-service @react-native-community/geolocationFor each new POC, update the following Android files:
-
android/app/build.gradle:android { defaultConfig { applicationId "com.yourpocname" // Update this } }
-
Rename package directory:
# From: android/app/src/main/java/com/meuapp/ # To: android/app/src/main/java/com/yourpocname/
-
Update package references in:
MainActivity.ktMainApplication.ktAndroidManifest.xml
Create your POC components in the components/ directory:
// components/YourFeature.tsx
import React from 'react';
import {View, Text, StyleSheet} from 'react-native';
export default function YourFeature() {
return (
<View style={styles.container}>
<Text>Your POC functionality here</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});// App.tsx - Template base
import React from 'react';
import {View, Text, StyleSheet, useColorScheme} from 'react-native';
import {SafeAreaProvider} from 'react-native-safe-area-context';
function AppContent() {
const isDarkMode = useColorScheme() === 'dark';
const textColor = isDarkMode ? 'white' : 'black';
return (
<View style={styles.container}>
<Text style={{color: textColor}}>Android POC Base Template</Text>
<Text style={{color: textColor}}>Implement your functionality here</Text>
</View>
);
}
export default function App() {
return (
<SafeAreaProvider>
<AppContent />
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});# Check if device is connected
adb devices
# If device shows "unauthorized":
# 1. Check USB cable connection
# 2. Look for USB debugging prompt on device
# 3. Revoke USB debugging authorizations in Developer options and reconnect# Clean Android build
cd android && ./gradlew clean
# Reset Metro cache
npm start -- --reset-cache
# Reinstall dependencies
rm -rf node_modules && npm install- Ensure Metro is running (
npm start) - Check that device and computer are on same network if using Wi-Fi debugging
- For USB: verify proper connection and drivers
- Try different USB ports
- Use original USB cable
- Check if USB debugging is properly enabled
- Restart both device and computer if needed
# List connected devices
adb devices
# Restart ADB server
adb kill-server && adb start-server
# View device logs
adb logcat
# Install APK directly
adb install app-debug.apkFor each new POC Android:
package.json- name and descriptionapp.json- name and displayNameandroid/app/build.gradle- applicationId- Rename folder:
android/app/src/main/java/com/meuapp/→android/app/src/main/java/com/[pocname]/ - Update package in Kotlin files (
MainActivity.kt,MainApplication.kt) - Update
AndroidManifest.xml App.tsx- implement functionalityREADME.md- specific documentation- Specific dependencies in package.json
- React Native Official Documentation
- Android Developer Setup
- TypeScript with React Native
- React Native Troubleshooting
This template provides a solid foundation for rapid POC development while maintaining code quality and development best practices.
Made with ❤️ for React Native Android Development