@@ -23,13 +23,6 @@ def isNewArchitectureEnabled() {
2323 return rootProject. hasProperty(" newArchEnabled" ) && rootProject. getProperty(" newArchEnabled" ) == " true"
2424}
2525
26- apply plugin : " com.android.library"
27- apply plugin : " kotlin-android"
28-
29- if (isNewArchitectureEnabled()) {
30- apply plugin : " com.facebook.react"
31- }
32-
3326def getExtOrDefault (name ) {
3427 return rootProject. ext. has(name) ? rootProject. ext. get(name) : project. properties[" RNQuickSQLite_" + name]
3528}
@@ -43,6 +36,12 @@ def safeAppExtGet(prop, fallback) {
4336 appProject?. ext?. has(prop) ? appProject. ext. get(prop) : fallback
4437}
4538
39+ def resolveBuildType () {
40+ Gradle gradle = getGradle()
41+ String tskReqStr = gradle. getStartParameter(). getTaskRequests()[' args' ]. toString()
42+ return tskReqStr. contains(' Release' ) ? ' release' : ' debug'
43+ }
44+
4645def supportsNamespace () {
4746 def parsed = com.android.Version . ANDROID_GRADLE_PLUGIN_VERSION . tokenize(' .' )
4847 def major = parsed[0 ]. toInteger()
@@ -64,19 +63,25 @@ def resolveReactNativeDirectory() {
6463 return reactNativePackage. parentFile
6564 }
6665
67- throw new GradleException (" [react-native-live-markdown ] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules." )
66+ throw new GradleException (" [react-native-quick-sqlite ] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules." )
6867}
6968
70- def getReactNativeMinorVersion () {
71- def reactNativeRootDir = resolveReactNativeDirectory()
72- def reactNativeProperties = new Properties ()
73- file(" $reactNativeRootDir /ReactAndroid/gradle.properties" ). withInputStream { reactNativeProperties. load(it) }
74- def reactNativeVersion = reactNativeProperties. getProperty(" VERSION_NAME" )
75- return reactNativeVersion. split(" \\ ." )[1 ]. toInteger()
76- }
69+ def reactNativeRootDir = resolveReactNativeDirectory()
70+ def reactProperties = new Properties ()
71+ file(" $reactNativeRootDir /ReactAndroid/gradle.properties" ). withInputStream { reactProperties. load(it) }
72+
73+ def REACT_NATIVE_VERSION = reactProperties. getProperty(" VERSION_NAME" )
74+ def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION . startsWith(" 0.0.0-" ) ? 1000 : REACT_NATIVE_VERSION . split(" \\ ." )[1 ]. toInteger()
7775
7876def SQLITE_FLAGS = rootProject. properties[' quickSqliteFlags' ]
7977
78+ apply plugin : " com.android.library"
79+ apply plugin : " kotlin-android"
80+
81+ if (isNewArchitectureEnabled()) {
82+ apply plugin : " com.facebook.react"
83+ }
84+
8085android {
8186 if (supportsNamespace()) {
8287 namespace " com.margelo.rnquicksqlite"
@@ -95,14 +100,14 @@ android {
95100 minSdkVersion getExtOrIntegerDefault(" minSdkVersion" )
96101 targetSdkVersion getExtOrIntegerDefault(" targetSdkVersion" )
97102
98- buildConfigField " int" , " REACT_NATIVE_MINOR_VERSION" , getReactNativeMinorVersion() . toString()
103+ buildConfigField " int" , " REACT_NATIVE_MINOR_VERSION" , REACT_NATIVE_MINOR_VERSION . toString()
99104 buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
100105
101106 externalNativeBuild {
102107 cmake {
103108 arguments " -DANDROID_STL=c++_shared" ,
104109 " -DANDROID_TOOLCHAIN=clang" ,
105- " -DREACT_NATIVE_MINOR_VERSION=${ getReactNativeMinorVersion() } " ,
110+ " -DREACT_NATIVE_MINOR_VERSION=${ REACT_NATIVE_MINOR_VERSION } " ,
106111 " -DSQLITE_FLAGS='${ SQLITE_FLAGS ? SQLITE_FLAGS : ''} '"
107112 abiFilters (* reactNativeArchitectures())
108113 }
@@ -112,6 +117,7 @@ android {
112117 externalNativeBuild {
113118 cmake {
114119 path " CMakeLists.txt"
120+ version = System . getenv(" CMAKE_VERSION" ) ?: " 3.22.1"
115121 }
116122 }
117123
@@ -151,6 +157,7 @@ android {
151157 }
152158
153159 packagingOptions {
160+ doNotStrip resolveBuildType() == ' debug' ? " **/**/*.so" : ' '
154161 excludes = [
155162 " META-INF" ,
156163 " META-INF/**" ,
0 commit comments