Steps to Rename Your Package in One Go:
Refactor Directories:
Right-click on the package → Refactor → Rename → Choose to rename all directories.
Update Gradle File:
Open app/build.gradle and update both the namespace (in android) and the applicationId (in defaultConfig).
Check Manifest:
Ensure the package attribute (if specified) in AndroidManifest.xml reflects the new package name.
Clean & Rebuild: Clean the project and rebuild to apply all changes.
If that didn't work, check this detailed solution on StackOverflow.