How to Change Package Name in Flutter?
In this article, we will discuss how to change package name in flutter?
Packages, according to Flutterdocs, can be explained as “shared packages contributed by other developers to the Flutter and Dart ecosystems. It will allow developers to quickly build an app without having to develop everything from scratch.”
In Flutter, Dart organizes and shares a set of functionality through a package. Flutter always supports shared packages, which is contributed by other developers to the Flutter and Dart ecosystem. The packages allow us to build the app without having to develop everything from scratch.
The application Package Name is specified in the package attribute of the manifest element. It follows the Java naming conventions and, by default, is the same as the name of the package to which the class implemented for the application belongs.
It uses to identify the application uniquely on devices and play store and app store. Changing the package name need to be done separately for android and iOS.
Depending on the type of platform, users can make changes in package names in flutter applications. We will about the same in both Android as well as iOS.
Follow steps as listed below to Change Package Name in Flutter for Android :
- Change the label name in your AndroidManifest.xml file:
<application android:name="io.flutter.app.FlutterApplication" android:label="TheNameOfYourApp" </application>
2. Change the Package in your AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.package.name">
3. In your build.gradle file inside the app folder
defaultConfig { applicationId "your.package.name" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
It will look like below :
AndroidManifest.xml
4. Finally, change the package in your MainActivity.java class
package your.package.name; import android.os.Bundle; import io.flutter.app.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant; public class MainActivity extends FlutterActivity {
5. Change the directory name :
From :
android\app\src\main\java\com\example\name
To :
android\app\src\main\java\com\example\name
Follow steps as listed below to Change Package Name in Flutter for iOS :
Change the bundle identifier from your Info.plist file inside your ios/Runner directory.
<key>CFBundleIdentifier</key> <string>com.your.packagename</string>
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
It’s recommended to run flutter clean after making changes.
Thanks for being with us Flutter Journey !!!
steve88test
thanks bro for this article which i found is very latest…but couldnt complete step 4 and 5 from your blog..i had to do more digging …now step 4 is mainactivity.kt kotlin class, and step 5 is app->src->main->kotlin class…checkout and please update for other newbies.
Somyarajsinh jadeja
Glad you found it bro. Thanks for the tip!!