Skip to content

Commit

Permalink
Fix android compilation for older RN versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Franco committed Aug 1, 2022
1 parent 2f08850 commit e1b12e2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Paths
import groovy.json.JsonSlurper

buildscript {
repositories {
Expand Down Expand Up @@ -44,6 +45,11 @@ def nodeModules = findNodeModules(projectDir);
logger.warn("react-native-quick-sqlite: node_modules/ found at: ${nodeModules}");

def reactNative = new File("$nodeModules/react-native")
def reactNativeManifest = file("$reactNative/package.json")
def reactNativeManifestAsJson = new JsonSlurper().parseText(reactNativeManifest.text)
def reactNativeVersion = reactNativeManifestAsJson.version as String
def (major, minor, patch) = reactNativeVersion.tokenize('.')
def rnMinorVersion = Integer.parseInt(minor)

def reactProperties = new Properties()
file("$nodeModules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
Expand Down Expand Up @@ -187,10 +193,12 @@ dependencies {
}
})
def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
if (rnMinorVersion < 69) {
rnAarMatcher = "**/**/*.aar"
}
def rnAAR = fileTree("$reactNative/android").matching({ it.include rnAarMatcher }).singleFile
def jscAAR = fileTree("${nodeModules}/jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile


extractJNI(files(rnAAR, jscAAR))
}

Expand Down

0 comments on commit e1b12e2

Please sign in to comment.