Reputation: 412
I have made an application using Flutter. However, now I want to change the domain name I initially used while creating the application. How can I do that?
Most of the answers on Stackoverflow explain how to change package name and domain name in normal Android Studio projects (not for Flutter projects).
Upvotes: 6
Views: 8135
Reputation: 494
I picked to try Casareafer's suggested approach. Here is how I did it my way while my project had firebase
as well. That should work for anyone. Make sure you have proper access to the connected firebase
account.
Delete android
and ios
directories.
Delete pubspec.lock
file.
Run the following command:
flutter create . --org com.yourdomain --platform ios,android
It will create fresh android and ios directories keeping all the rest same. You're done with your updated domain.
Now you have to restore the services like firebase
. Specifically for firebase it's pretty simple. Ensure that you have firebase CLI and flutterfire CLI installed Check the doc
flutterfire configure
flutter run
If you face any issues try using:
flutter pub cache repair
and then
flutter run
Upvotes: 0
Reputation: 165
To change your domain name and to save some headaches, redo iOS and Android Folders:
If your project doesn't have android or iOS specific files like
GoogleService-Info.plist
or
google-services.json
you could safely delete both ios and android folder from your project root directory, just have in mind all the stuff you'd need to set up later and then run in the project root directory the following command
flutter create . --org com.foo.bar
then it will regenerate both ios and android projects configured with your desired domain(com.foo.bar) and will add your project name after the domain (com.foo.bar.you_project_name); Your build.gradle will look something like this:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.foo.bar.YOUR_PROJECT_NAME"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
If your iOS or Android project contain specific files, you could just back up them, then do the above steps and finally add up the files to the project or generate new files.. I find these steps more convenient and less prune to mistakes than having to search variables in different files within the project and change directory names,
Pros: Faster, Easier than changing names, no need to fix in-code packages imports & folders because they're generated automatically, less prone to make mistakes
Cons: building the projects might use old gradle&kotlin versions so probably you need to update these, need to declare dependencies i.e firebase, need to restore specific files
Upvotes: 2
Reputation: 9913
For Android project (android folder of Flutter project):
For iOS project (ios folder of Flutter project):
Upvotes: 8