extractAndroidBuildSettings function
Reads the Android build settings from whichever of android/build.gradle
/ android/build.gradle.kts is present in androidGradleFileContents
(as produced by extractArchiveEntries(bytes, isAndroidGradleFilePath)).
Returns null when neither file is present.
Implementation
AndroidBuildSettings? extractAndroidBuildSettings(
Map<String, List<int>> androidGradleFileContents,
) {
final content =
androidGradleFileContents['android/build.gradle'] ??
androidGradleFileContents['android/build.gradle.kts'];
if (content == null) return null;
final text = _stripLineComments(utf8.decode(content));
return AndroidBuildSettings(
compileSdk: _firstMatch(_compileSdkPattern, text),
agpVersion:
_firstMatch(_agpClasspathPattern, text) ??
_firstMatch(_agpPluginsDslPattern, text),
ndkVersion: _firstMatch(_ndkVersionPattern, text),
);
}