resolveMinSdkAndroid function

Future<int> resolveMinSdkAndroid({
  1. required String prefixPath,
  2. required FLILogger logger,
  3. required int? explicit,
})

Resolves the effective Android min_sdk_android for a generation run.

Resolution order (first non-null wins):

  1. explicit — the user-supplied value from min_sdk_android in their config (passed through verbatim).
  2. minSdk — autodetected from build.gradle[.kts] / local.properties rooted at prefixPath.
  3. constants.androidDefaultAndroidMinSDK (currently 24). When this branch is taken, a warning is emitted via logger using constants.errorMissingMinSdk so the user knows autodetection failed.

Returns the resolved integer. Never returns null.

Implementation

Future<int> resolveMinSdkAndroid({
  required String prefixPath,
  required FLILogger logger,
  required int? explicit,
}) async {
  if (explicit != null) {
    logger.verbose(
      'Android min_sdk_android: using explicit user value $explicit '
      '(autodetect skipped).',
    );
    return explicit;
  }
  final detected = await minSdk(prefixPath: prefixPath);
  if (detected != null) {
    logger.verbose(
      'Android min_sdk_android: autodetected $detected from gradle.',
    );
    return detected;
  }
  logger.warn(constants.errorMissingMinSdk);
  logger.verbose(
    'Android min_sdk_android: falling back to static default '
    '${constants.androidDefaultAndroidMinSDK}.',
  );
  return constants.androidDefaultAndroidMinSDK;
}