@@ -39,6 +39,7 @@ EventEmitter.defaultMaxListeners = 100;
3939
4040// This should match https://github.com/react-native-community/template/blob/main/template/android/build.gradle#L7
4141const DEFAULT_NDK_VERSION = "27.1.12297006" ;
42+ const DEFAULT_ANDROID_SDK_VERSION = "24" ;
4243
4344// TODO: Add automatic ccache support
4445
@@ -88,6 +89,11 @@ const ndkVersionOption = new Option(
8889 "The NDK version to use for Android builds"
8990) . default ( DEFAULT_NDK_VERSION ) ;
9091
92+ const androidSdkVersionOption = new Option (
93+ "--android-sdk-version <version>" ,
94+ "The Android SDK version to use for Android builds"
95+ ) . default ( DEFAULT_ANDROID_SDK_VERSION ) ;
96+
9197const noAutoLinkOption = new Option (
9298 "--no-auto-link" ,
9399 "Don't mark the output as auto-linkable by react-native-node-api"
@@ -115,6 +121,7 @@ export const program = new Command("cmake-rn")
115121 . addOption ( outPathOption )
116122 . addOption ( cleanOption )
117123 . addOption ( ndkVersionOption )
124+ . addOption ( androidSdkVersionOption )
118125 . addOption ( noAutoLinkOption )
119126 . addOption ( noWeakNodeApiLinkageOption )
120127 . addOption ( xcframeworkExtensionOption )
@@ -348,12 +355,19 @@ function getTripletBuildPath(buildPath: string, triplet: SupportedTriplet) {
348355
349356function getTripletConfigureCmakeArgs (
350357 triplet : SupportedTriplet ,
351- { ndkVersion } : Pick < GlobalContext , "ndkVersion" | "weakNodeApiLinkage" >
358+ {
359+ ndkVersion,
360+ androidSdkVersion,
361+ } : Pick <
362+ GlobalContext ,
363+ "ndkVersion" | "androidSdkVersion" | "weakNodeApiLinkage"
364+ >
352365) {
353366 if ( isAndroidTriplet ( triplet ) ) {
354367 return getAndroidConfigureCmakeArgs ( {
355368 triplet,
356369 ndkVersion,
370+ sdkVersion : androidSdkVersion ,
357371 } ) ;
358372 } else if ( isAppleTriplet ( triplet ) ) {
359373 return getAppleConfigureCmakeArgs ( { triplet } ) ;
@@ -379,6 +393,7 @@ async function configureProject(context: TripletScopedContext) {
379393 tripletBuildPath,
380394 source,
381395 ndkVersion,
396+ androidSdkVersion,
382397 weakNodeApiLinkage,
383398 } = context ;
384399 await spawn (
@@ -392,6 +407,7 @@ async function configureProject(context: TripletScopedContext) {
392407 ...getTripletConfigureCmakeArgs ( triplet , {
393408 ndkVersion,
394409 weakNodeApiLinkage,
410+ androidSdkVersion,
395411 } ) ,
396412 ] ,
397413 {
0 commit comments