Is there any way to change Package Name of Flutter project?
I want to change package name and application name in flutter project.
Select Refactor. Click on Rename. In the Pop-up dialog, click on Rename Package instead of Rename Directory. Enter the new name and hit Refactor.
For Android App Name
Change the label name in your AndroidManifest.xml
file:
<application android:name="io.flutter.app.FlutterApplication" android:label="TheNameOfYourApp"
For Package Name
Change the package name in your AndroidManifest.xml
(in 3 of them, folders: main, debug and profile, according what environment you want to deploy) file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.package.name">
Also in your build.gradle
file inside app folder
defaultConfig { applicationId "your.package.name" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
Finally, change the package in your MainActivity.java
class (if the MainActivity.java is not available, check the MainActivity.kt)
package your.package.name; import android.os.Bundle; import io.flutter.app.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant; public class MainActivity extends FlutterActivity {
Change the directory name:
From:
android\app\src\main\java\com\example\name
To:
android\app\src\main\java\your\package\name
EDITED : 27-Dec-18
for package name just change in build build.gradle
only
defaultConfig { applicationId "your.package.name" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
For iOS
Change the bundle identifier from your Info.plist
file inside your ios/Runner
directory.
<key>CFBundleIdentifier</key> <string>com.your.packagename</string>
UPDATE
To avoid renaming the package and bundle identifier, you can start your project using this command in your terminal:
flutter create --org com.yourdomain appname
Changing name manually doesn't seem to work, throws gradle errors, well in my case it does throw error.
So I usually create a new flutter project.
I use below mentioned command to create a new flutter app
flutter create --org com.yourdomain appname
your project will have the package name as -> com.yourdomain.appname
if you just want to keep your package name as com.appname
then make some changes as below
flutter create --org com appname
to add java instead of kotlin
for android
add -a java
flutter create -a java --org com.yourdomain appname
EDIT
If you have already created a project you can use change_app_package_name package to change the package name.
flutter pub run change_app_package_name:main com.package.appname
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With