Is there any way to change Package Name of Flutter project?
I want to change package name and application name in flutter project.
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
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
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
Answer:
Change name
attribute in pubspec.yaml
(line 1)
For the name of apk, change android:label
in AndroidManifest.xml
Answer:
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
Answer:
Android
In Android the package name is in the AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
package="com.example.appname">
iOS
In iOS the package name is the bundle identifier in Info.plist:
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
which is found in Runner.xcodeproj/project.pbxproj:
PRODUCT_BUNDLE_IDENTIFIER = com.example.appname;
Changing the name
The package name is found in more than one location, so to change the name you should search the whole project for occurrences of your old project name and change them all.
Android Studio and VS Code:
- Mac: Command + Shift + F
- Linux/Windows: Ctrl + Shift + F
Thanks to diegoveloper for help with iOS.
Update:
After coming back to this page a few different times, I’m thinking it’s just easier and cleaner to start a new project with the right name and then copy the old files over.
Answer:
change in all AndroidManifest.xml files of your Flutter Project, –> package=”your.name.app”
(app/src/debug/AndroidManifest.xml) and
(app/src/main/AndroidManifest.xml) and (app/src/profile/AndroidManifest.xml)
good look !!
Answer:
Updated You have to change the package name to your desired package name in these
five location.
1.) src/profile/AndroidManifest.xml
2.) src/debug/AndroidManifest.xml
3.) src/main/AdroidManifest.xml
4.) build.gradle .
defaultConfig {
applicationId
5.) MainActivity.java on "package"
last step is to run flutter clean
Answer:
This is how i renamed package for both ios and android
- Go to build.gradle in app module and rename
applicationId "com.company.name"
- Go to Manifest.xml in
app/src/main
and renamepackage="com.company.name"
andandroid:label="App Name"
- Go to Manifest.xml in
app/src/debug
and renamepackage="com.company.name"
- Go to Manifest.xml in
app/src/profile
and renamepackage="com.company.name"
- Go to
app/src/main/kotlin/com/something/something/MainActivity.kt
and renamepackage="com.company.name"
- Go to
app/src/main/kotlin/
and rename each directory so that the structure looks likeapp/src/main/kotlin/com/company/name/
- Go to
pubspec.yaml
in your project and changename: something
toname: name
, example :- if package name iscom.abc.xyz
thename: xyz
- Go to each dart file in lib folder and rename the imports to the modified name.
- Open XCode and open the runner file and click on Runner in project explorer.
- Go to General -> double click on Bundle Identifier -> rename it to
com.company.name
- Go to Info.plist click on Bundle name -> rename it to your App Name.
- close everything -> go to your flutter project and run this command in terminal
flutter clean
Answer:
Answer:
You can follow this official documentation by Google: https://developer.android.com/studio/build/application-id.html
Application ID should be changed in Build.gradle, while package name can be changed in AndroidManifest.xml.
However one should be careful changing package name.
Also while re uploading the app, one should be careful since it matches the application ID of previously uploaded app with new upload.
Answer:
On Visual Studio code
Edit > Replace in Files
On Android studio
1. Right click on your project > Replace in path
2. Write your old package and new package > Replace all
Tags: androidandroid