Skip to content

Commit 0738839

Browse files
committed
fix: build.gradle
1 parent 826391b commit 0738839

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

package/android/build.gradle

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
3326
def 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+
4645
def supportsNamespace() {
4746
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
4847
def major = parsed[0].toInteger()
@@ -64,7 +63,7 @@ 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

7069
def getReactNativeMinorVersion() {
@@ -77,6 +76,13 @@ def getReactNativeMinorVersion() {
7776

7877
def SQLITE_FLAGS = rootProject.properties['quickSqliteFlags']
7978

79+
apply plugin: "com.android.library"
80+
apply plugin: "kotlin-android"
81+
82+
if (isNewArchitectureEnabled()) {
83+
apply plugin: "com.facebook.react"
84+
}
85+
8086
android {
8187
if (supportsNamespace()) {
8288
namespace "com.margelo.rnquicksqlite"
@@ -102,7 +108,7 @@ android {
102108
cmake {
103109
arguments "-DANDROID_STL=c++_shared",
104110
"-DANDROID_TOOLCHAIN=clang",
105-
"-DREACT_NATIVE_MINOR_VERSION=${getReactNativeMinorVersion()}",
111+
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
106112
"-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'"
107113
abiFilters (*reactNativeArchitectures())
108114
}
@@ -112,6 +118,7 @@ android {
112118
externalNativeBuild {
113119
cmake {
114120
path "CMakeLists.txt"
121+
version = System.getenv("CMAKE_VERSION") ?: "3.22.1"
115122
}
116123
}
117124

@@ -151,7 +158,7 @@ android {
151158
}
152159

153160
packagingOptions {
154-
doNotStrip '**/**/*.so'
161+
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
155162
excludes = [
156163
"META-INF",
157164
"META-INF/**",

0 commit comments

Comments
 (0)