Version: 0.1

# Add Package to Existing App

### In this tutorial, you will learn how to add the PyTorch Live core package to an existing React Native project.​

If you have an existing React Native project and you want to add ML capabilities, you can add the react-native-pytorch-core package. This package includes all code needed to run ML inference, the Canvas, Camera, and the ImageUtils.

## Installation​

yarn add react-native-pytorch-core

On iOS you are done, but Android requires the following additional steps for the react-native-pytorch-core package to work.

If the PyTorch Mobile models are part of the React Native bundle, the Metro configuration needs to be changed to resolve the ptl files.

note

This is only required if models are loaded from the bundle using require('./path/to/model.ptl'). It is not required if models are loaded from the local file system or via a URL.

metro.config.js
// get defaults assetExts arrayconst defaultAssetExts = require('metro-config/src/defaults/defaults')  .assetExts;module.exports = {  // ...  resolver: {    assetExts: [...defaultAssetExts, 'ptl'],  },  // ...};

For the react-native-pytorch-core React Native package to work on Android, it requires three changes to the gradle.properties and the two build.gradle files to increase JVM memory, add Sonatype repository, and packaging options with pick first rule.

#### Increase JVM Memory​

Increase the memory for the JVM to avoid OutOfMemory exceptions during the packaging process.

org.gradle.jvmargs=-Xmx4g