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
For those like me that doesn't like to change specific files, I've used https://pub.dev/packages/rename.
Using this, you simply run these commands in your terminal and your app name and identifiers will be changed.pub global run
Installing: pub global activate rename
And then, Run this command inside your flutter project root.
pub global run rename --bundleId com.example.android.app --target android
In Android the package name is in the AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
package="com.example.appname">
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;
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:
Thanks to diegoveloper for help with iOS.
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.
Change name
attribute in pubspec.yaml
(line 1)
For the name of apk, change android:label
in AndroidManifest.xml
This is how i renamed package for both ios and android
applicationId "com.company.name"
app/src/main
and rename package="com.company.name"
and android:label="App Name"
app/src/debug
and rename package="com.company.name"
app/src/profile
and rename package="com.company.name"
app/src/main/kotlin/com/something/something/MainActivity.kt
and rename package="com.company.name"
app/src/main/kotlin/
and rename each directory so that the structure looks like app/src/main/kotlin/com/company/name/
pubspec.yaml
in your project and change name: something
to name: name
, example :- if package name is com.abc.xyz
the name: xyz
com.company.name
flutter clean
According to the official flutter documentation you just need to change the ApplicationId
in app/build.gradle
directory. Then you have to just build your apk and the package name of the manifest file will be changed according to the ApplicationId
you changed in build.gradle
. Because of flutter while building an apk and google play both consider ApplicationId
from build.gradle. This solution worked for me.
source: Official Documentation
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 !!
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
Change App Package Name with single command
by using following package. It makes the process very easy and fast.
flutter pub run change_app_package_name:main com.new.package.name
Quickest and cleanest way to change your package name :
Warning : You may want to save some files in android/ and ios/ folder before it gets deleted !
android/
ios/
build/
Let's say you want to rename from com.oldcompany.oldproject
to com.newcompany.newproject
Launch the following code :
flutter create --org com.newcompany --project-name newproject .
PS : To make sure everything is set up correctly, you can search for your package names in your files, by typing the commands grep --color -r com.oldcompany.oldproject *
and grep --color -r com.newcompany.newproject *
After trying all of the above. Simple work for me to rename package flutter with Android Studio:
Step 1:
Mac: Command + Shift + R
Linux/Windows: Ctrl + Shift + R
After change to new package and press Replace All
and wait Android Studio run finish.
Step 2:
Next, go to AndroidManifest.xml
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name">
and copy package name
and do the same Step 1 to rename package
in AndroidManifest
and build.gradle
.
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. For details see the following link this:
From:
android\app\src\main\java\com\example\name
To:
android\app\src\main\java\your\new_package\name
Even if my answer wont be accepted as the correct answer, I just feel all these answers above caused me to have more problems here is how I fixed it
Conclusion: a simple find and replace program is all you need to sort this problem out, and I strongly recommend Sublime Text 3 for that.
the right to change path for default way for both Android and Ios.
for Android
open AndroidManifest.xml,
app/src/main/AndroidManifest.xml
__________________________________________________________________________
for Ios
change_app_package_name
packagejust add the above package in dev dependencies
dev_dependencies:
flutter_test:
sdk: flutter
change_app_package_name: ^0.1.2
and run the following command, replace "com.new.package.name" with your new package name
flutter pub run change_app_package_name:main com.new.package.name
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.
In Android, change application id in
> build.gradle
file and iOS change
> bundle name from project settings.
To change package name in flutter , you have to do it for all platforms.
To make it easier, I suggest you to use rename package .
Just run this command inside your flutter project root.
pub global run rename --bundleId com.onat.networkApp
Here, com.onat.networkApp is your package name
To target a specific platform use the "-t" option. e.g:
pub global run rename --bundleId com.example.android.app -t android
You can learn more about rename package here
If you don’t like changing files in such a way then alternative way would be to use this package.
https://pub.dev/packages/rename
rename --bundleId com.newpackage.appname
pub global run rename --appname "Your New App Name"
Using this, you simply run these 2 commands in your terminal and your app name and identifiers will be changed.pub global run
Source: Stackoverflow.com