Skip to content

Commit bb93132

Browse files
android: use minSdkVersion to build native modules
Uses the minSdkVersion or the version nodejs-mobile was built with to build the native modules.
1 parent 5e37e7a commit bb93132

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

android/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ buildscript {
1212
apply plugin: 'com.android.library'
1313

1414
def _nodeTargetSdkVersion = ((rootProject?.ext?.properties?.targetSdkVersion) ?: 22)
15-
15+
def _nodeMinSdkVersion = ((rootProject?.ext?.properties?.minSdkVersion) ?: 16)
16+
def _compileNativeModulesSdkVersion = _nodeMinSdkVersion;
17+
if (_compileNativeModulesSdkVersion<21) {
18+
// 21 is the minimum sdk version Node is built with.
19+
_compileNativeModulesSdkVersion=21;
20+
}
1621
def DoesAppAlreadyDefineWantedSTL() {
1722
// Since react-native 0.59.0, the Application already defines libc++_shared as the APP_STL.
1823
// Defining it also in this plugin would lead to a build error when merging assets.
@@ -47,7 +52,7 @@ android {
4752
buildToolsVersion ((rootProject?.ext?.properties?.buildToolsVersion) ?: "23.0.1")
4853

4954
defaultConfig {
50-
minSdkVersion ((rootProject?.ext?.properties?.minSdkVersion) ?: 16)
55+
minSdkVersion _nodeMinSdkVersion
5156
targetSdkVersion _nodeTargetSdkVersion
5257
versionCode 1
5358
versionName "1.0"
@@ -336,7 +341,7 @@ if ("1".equals(shouldRebuildNativeModules)) {
336341
task "MakeToolchain${abi_name}" (type:Exec) {
337342
description = "Building a native toolchain to compile nodejs-mobile native modules for ${abi_name}."
338343
executable = "${ndk_bundle_path}/build/tools/make-standalone-toolchain.sh"
339-
args "--toolchain=${temp_toolchain_name}-${temp_cc_ver}", "--arch=${temp_arch}", "--install-dir=${standalone_toolchain}", "--stl=libc++", "--force", "--platform=android-${_nodeTargetSdkVersion}"
344+
args "--toolchain=${temp_toolchain_name}-${temp_cc_ver}", "--arch=${temp_arch}", "--install-dir=${standalone_toolchain}", "--stl=libc++", "--force", "--platform=android-${_compileNativeModulesSdkVersion}"
340345
outputs.file "${standalone_toolchain}"
341346
}
342347

0 commit comments

Comments
 (0)