Skip to content

Commit 44336c8

Browse files
authored
Add support for React Native 0.69+ (#15)
1 parent fe689b6 commit 44336c8

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

android/build.gradle

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ if(!found) {
5454

5555
def nodeModulesPath = nodeModulesDir.toString().replace("\\", "/")
5656
def reactNativePath = reactNativeDir.toString().replace("\\", "/")
57-
57+
def buildType() {
58+
def buildType = "debug"
59+
60+
tasks.all({ task ->
61+
if (task.name == "buildCMakeRelease") {
62+
buildType = "release"
63+
}
64+
})
65+
66+
return buildType
67+
}
5868

5969
android {
6070
compileSdkVersion getExtOrDefault('compileSdkVersion', 28)
@@ -108,11 +118,19 @@ repositories {
108118
}
109119
}
110120

121+
def reactProperties = new Properties()
122+
file("$nodeModulesPath/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
123+
124+
def reactNativeVersion = reactProperties.getProperty("VERSION_NAME").split("\\.")[1].toInteger()
125+
111126
dependencies {
112127
//noinspection GradleDynamicVersion
113128
implementation 'com.facebook.react:react-native:+'
129+
def rnMatcher = reactNativeVersion < 69
130+
? "**/**/*.aar"
131+
: "**/react-native/**/*${buildType()}.aar"
114132

115-
def rnAAR = fileTree(reactNativePath).matching({ it.include "**/**/*.aar" }).singleFile
133+
def rnAAR = fileTree(reactNativePath).matching({ it.include rnMatcher }).singleFile
116134
extractJNI(files(rnAAR))
117135
}
118136

@@ -136,4 +154,4 @@ task extractJNIFiles {
136154
// Extract JNI files as soon as first task is added
137155
tasks.whenTaskAdded { task ->
138156
task.dependsOn(extractJNIFiles);
139-
}
157+
}

0 commit comments

Comments
 (0)