Skip to content

Commit

Permalink
Android: Fix build for React Native v0.71
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed May 26, 2023
1 parent 3c05e1d commit e037a60
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions js/react_native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def checkIfOrtExtensionsEnabled() {

boolean ortExtensionsEnabled = checkIfOrtExtensionsEnabled()

def REACT_NATIVE_VERSION = ['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()

android {
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
buildToolsVersion getExtOrDefault('buildToolsVersion')
Expand All @@ -78,7 +81,12 @@ android {
externalNativeBuild {
cmake {
cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all"
arguments "-DNODE_MODULES_DIR=${nodeModules}"
if (REACT_NATIVE_MINOR_VERSION >= 71) {
// fabricjni required c++_shared
arguments "-DANDROID_STL=c++_shared", "-DNODE_MODULES_DIR=${nodeModules}", "-DORT_EXTENSIONS_ENABLED=${ortExtensionsEnabled}"
} else {
arguments "-DNODE_MODULES_DIR=${nodeModules}"
}
abiFilters (*reactNativeArchitectures())
}
}
Expand Down Expand Up @@ -210,8 +218,6 @@ repositories {
}
}

def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

dependencies {
api "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
api "org.mockito:mockito-core:2.28.2"
Expand Down

0 comments on commit e037a60

Please sign in to comment.