process method
Implementation
Future<void> process() async {
print("Running for android");
var gradleFile = PATH_BUILD_GRADLE;
if(!await File(gradleFile).exists()) {
gradleFile = "$gradleFile.kts";
}
if (!await File(gradleFile).exists()) {
print('ERROR:: build.gradle file not found, Check if you have a correct android directory present in your project'
'\n\nrun " flutter create . " to regenerate missing files.');
return;
}
String? contents = await readFileAsString(gradleFile);
var reg = RegExp(r'applicationId\s*=?\s*"(.*)"', caseSensitive: true, multiLine: false);
var match = reg.firstMatch(contents!);
if(match == null) {
print('ERROR:: applicationId not found in build.gradle file, Please file an issue on github with $gradleFile file attached.');
return;
}
var name = match.group(1);
oldPackageName = name;
print("Old Package Name: $oldPackageName");
print('Updating build.gradle File');
await _replace(gradleFile);
var mText = 'package="$newPackageName">';
var mRegex = '(package=.*)';
print('Updating Main Manifest file');
await replaceInFileRegex(PATH_MANIFEST, mRegex, mText);
print('Updating Debug Manifest file');
await replaceInFileRegex(PATH_MANIFEST_DEBUG, mRegex, mText);
print('Updating Profile Manifest file');
await replaceInFileRegex(PATH_MANIFEST_PROFILE, mRegex, mText);
await updateMainActivity();
print('Finished updating android package name');
}