process method
Implementation
Future<void> process() async {
print("Running for android");
if (!await File(PATH_BUILD_GRADLE).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(PATH_BUILD_GRADLE);
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 $PATH_BUILD_GRADLE file attached.');
return;
}
var name = match.group(1);
oldPackageName = name;
print("Old Package Name: $oldPackageName");
print('Updating build.gradle File');
await _replace(PATH_BUILD_GRADLE);
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');
}