@@ -298,15 +298,29 @@ List<String> transformAndroidManifestWithNewLauncherIcon(
298
298
}).toList ();
299
299
}
300
300
301
- /// Retrieves the minSdk value from the Android build.gradle file
301
+ /// Retrieves the minSdk value from the Android build.gradle file or local.properties file
302
302
int minSdk () {
303
- final File androidGradleFile = File (constants.androidGradleFile);
304
- final List <String > lines = androidGradleFile.readAsLinesSync ();
303
+ final androidGradleFile = File (constants.androidGradleFile);
304
+ final androidLocalPropertiesFile = File (constants.androidLocalPropertiesFile);
305
+
306
+ // look in build.gradle first
307
+ final minSdkValue = getMinSdkFromFile (androidGradleFile);
308
+
309
+ // look in local.properties. Didn't find minSdk, assume the worst
310
+ return minSdkValue != 0
311
+ ? minSdkValue
312
+ : getMinSdkFromFile (androidLocalPropertiesFile);
313
+ }
314
+
315
+ /// Retrieves the minSdk value from [File]
316
+ int getMinSdkFromFile (File file) {
317
+ final List <String > lines = file.readAsLinesSync ();
305
318
for (String line in lines) {
306
319
if (line.contains ('minSdkVersion' )) {
307
320
// remove anything from the line that is not a digit
308
321
final String minSdk = line.replaceAll (RegExp (r'[^\d]' ), '' );
309
- return int .parse (minSdk);
322
+ // when minSdkVersion value not found
323
+ return int .tryParse (minSdk) ?? 0 ;
310
324
}
311
325
}
312
326
return 0 ; // Didn't find minSdk, assume the worst
0 commit comments