3

I have added rename: ^2.0.1 and gave pub get. then I run this command

pub global run rename --bundleId com.hit.fantomcarpentry

but Im getting below error,

'pub' is not recognized as an internal or external command, operable program or batch file.

how to correct this. I want to change my package name.

current package name

package="com.hit.fixing_to_do"

enter image description here

asked May 12, 2022 at 7:34

4 Answers 4

3

Try this command, you should include flutter before pub in command and make sure you are in the project directory:

flutter pub global run rename --bundleId com.hit.fantomcarpentry

If not work follow alternative solution:

You can use change_app_package_name.

To use this, add this package in pubsec.yaml

dev_dependencies: 
 change_app_package_name: ^1.0.0

Not migrated to null safety yet? use old version like this

dev_dependencies: 
 change_app_package_name: ^0.1.3

then run this command in project directory:

flutter pub get
flutter pub run change_app_package_name:main com.new.package.name
answered May 12, 2022 at 7:39
Sign up to request clarification or add additional context in comments.

1 Comment

If I do this does it create a new package (new url) on pub.dev or does it use the existing url/package location on pub just with a different name?
1

You can use https://pub.dev/packages/change_app_package_name

Add below in your pubspec.yaml file, save your file.

dev_dependencies: 
 change_app_package_name: ^1.1.0

and Run this command to change package name

flutter pub run change_app_package_name:main com.new.package.name
answered Mar 23, 2023 at 20:33

Comments

0

This is how you can renamed package for both ios and android

  1. Go to build.gradle in app module and rename applicationId "com.company.name"

  2. Go to Manifest.xml in app/src/main and rename package="com.company.name" and android:label="App Name"

  3. Go to Manifest.xml in app/src/debug and rename package="com.company.name"

  4. Go to Manifest.xml in app/src/profile and rename package="com.company.name"

  5. Go to app/src/main/kotlin/com/something/something/MainActivity.kt and rename package="com.company.name"

  6. Go to app/src/main/kotlin/ and rename each directory so that the structure looks like app/src/main/kotlin/com/company/name/

  7. Go to pubspec.yaml in your project and change name: something to name: name, example :- if package name is com.abc.xyz the name: xyz

  8. Go to each dart file in lib folder and rename the imports to the modified name.

  9. Open XCode and open the runner file and click on Runner in project explorer.

  10. Go to General -> double click on Bundle Identifier -> rename it to com.company.name

  11. 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

Comments

0

To Change package name 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>

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.