Skip to content

Commit

Permalink
fix: make Android new arch build work RN 0.75
Browse files Browse the repository at this point in the history
  • Loading branch information
zewish committed Oct 16, 2024
1 parent 0e0db96 commit d918b0e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion packages/react-native-avoid-softinput/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,36 @@ if (project == rootProject) {
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def safeAppExtGet(prop, fallback) {
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
}

def resolveReactNativeDirectory() {
def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
if (reactNativeLocation != null) {
return file(reactNativeLocation)
}

def reactNativeFromAppNodeModules = file("${projectDir}/../../react-native")
if (reactNativeFromAppNodeModules.exists()) {
return reactNativeFromAppNodeModules
}

def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
if (reactNativeFromProjectNodeModules.exists()) {
return reactNativeFromProjectNodeModules
}

throw new GradleException(
"[RNAvoidSoftInput] Unable to resolve react-native location in node_modules. You should add project extension property (in `app/build.gradle`) `REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
)
}

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"

def reactNativeDirectory = project.ext.resolveReactNativeDirectory()
def reactNativeDirectory = resolveReactNativeDirectory()

react {
reactNativeDir = file(reactNativeDirectory)
Expand Down

0 comments on commit d918b0e

Please sign in to comment.